move some UserInfo properties into separate adc/nmdc sub structs
--HG-- branch : adc
This commit is contained in:
parent
95cd5c85f0
commit
aabaa128c4
@ -24,13 +24,15 @@ func TestMyINFOParse(t *testing.T) {
|
|||||||
ClientVersion: "1.4.3",
|
ClientVersion: "1.4.3",
|
||||||
Email: "xyz@example.com",
|
Email: "xyz@example.com",
|
||||||
ShareSize: 53054999578,
|
ShareSize: 53054999578,
|
||||||
ConnectionMode: CONNECTIONMODE_PASSIVE,
|
|
||||||
Flag: FLAG_NORMAL,
|
Flag: FLAG_NORMAL,
|
||||||
Slots: 1,
|
Slots: 1,
|
||||||
Speed: "0.0",
|
|
||||||
HubsUnregistered: 9,
|
HubsUnregistered: 9,
|
||||||
HubsRegistered: 0,
|
HubsRegistered: 0,
|
||||||
HubsOperator: 2,
|
HubsOperator: 2,
|
||||||
|
UserInfo_NMDCOnly: UserInfo_NMDCOnly{
|
||||||
|
ConnectionMode: CONNECTIONMODE_PASSIVE,
|
||||||
|
Speed: "0.0",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
myInfoTestPair{
|
myInfoTestPair{
|
||||||
@ -38,22 +40,26 @@ func TestMyINFOParse(t *testing.T) {
|
|||||||
expect: UserInfo{
|
expect: UserInfo{
|
||||||
Nick: "ixxxxxxx0",
|
Nick: "ixxxxxxx0",
|
||||||
ClientVersion: "0", // Auto-inserted by the parser for short-format MyINFO strings
|
ClientVersion: "0", // Auto-inserted by the parser for short-format MyINFO strings
|
||||||
ConnectionMode: CONNECTIONMODE_PASSIVE,
|
|
||||||
Flag: UserFlag(rune('A')),
|
Flag: UserFlag(rune('A')),
|
||||||
|
UserInfo_NMDCOnly: UserInfo_NMDCOnly{
|
||||||
|
ConnectionMode: CONNECTIONMODE_PASSIVE,
|
||||||
Speed: "1",
|
Speed: "1",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
},
|
||||||
myInfoTestPair{
|
myInfoTestPair{
|
||||||
in: "$ALL SXXXX_XXXXXXR <ncdc V:1.19.1-12-g5561,M:P,H:1/0/0,S:10>$ $0.005Q$$0$",
|
in: "$ALL SXXXX_XXXXXXR <ncdc V:1.19.1-12-g5561,M:P,H:1/0/0,S:10>$ $0.005Q$$0$",
|
||||||
expect: UserInfo{
|
expect: UserInfo{
|
||||||
Nick: "SXXXX_XXXXXXR",
|
Nick: "SXXXX_XXXXXXR",
|
||||||
ClientTag: "ncdc",
|
ClientTag: "ncdc",
|
||||||
ClientVersion: "1.19.1-12-g5561",
|
ClientVersion: "1.19.1-12-g5561",
|
||||||
ConnectionMode: CONNECTIONMODE_PASSIVE,
|
|
||||||
Flag: UserFlag(rune('Q')),
|
Flag: UserFlag(rune('Q')),
|
||||||
Slots: 10,
|
Slots: 10,
|
||||||
Speed: "0.00",
|
|
||||||
HubsUnregistered: 1,
|
HubsUnregistered: 1,
|
||||||
|
UserInfo_NMDCOnly: UserInfo_NMDCOnly{
|
||||||
|
ConnectionMode: CONNECTIONMODE_PASSIVE,
|
||||||
|
Speed: "0.00",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
myInfoTestPair{
|
myInfoTestPair{
|
||||||
@ -63,10 +69,12 @@ func TestMyINFOParse(t *testing.T) {
|
|||||||
Description: "desccccc",
|
Description: "desccccc",
|
||||||
ClientTag: "HexChat",
|
ClientTag: "HexChat",
|
||||||
ClientVersion: "2.12.1",
|
ClientVersion: "2.12.1",
|
||||||
ConnectionMode: CONNECTIONMODE_PASSIVE,
|
|
||||||
Flag: UserFlag(rune('p')),
|
Flag: UserFlag(rune('p')),
|
||||||
HubsUnregistered: 1,
|
HubsUnregistered: 1,
|
||||||
Slots: 0,
|
Slots: 0,
|
||||||
|
UserInfo_NMDCOnly: UserInfo_NMDCOnly{
|
||||||
|
ConnectionMode: CONNECTIONMODE_PASSIVE,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
28
UserInfo.go
28
UserInfo.go
@ -8,21 +8,43 @@ type UserInfo struct {
|
|||||||
ClientVersion string
|
ClientVersion string
|
||||||
Email string
|
Email string
|
||||||
ShareSize uint64
|
ShareSize uint64
|
||||||
ConnectionMode ConnectionMode
|
|
||||||
Flag UserFlag
|
Flag UserFlag
|
||||||
Slots uint64
|
Slots uint64
|
||||||
Speed string
|
|
||||||
HubsUnregistered uint64
|
HubsUnregistered uint64
|
||||||
HubsRegistered uint64
|
HubsRegistered uint64
|
||||||
HubsOperator uint64
|
HubsOperator uint64
|
||||||
IsOperator bool
|
IsOperator bool
|
||||||
|
|
||||||
|
UserInfo_NMDCOnly
|
||||||
|
UserInfo_ADCOnly
|
||||||
|
}
|
||||||
|
|
||||||
|
type UserInfo_NMDCOnly struct {
|
||||||
|
Speed string
|
||||||
IPAddress string
|
IPAddress string
|
||||||
|
ConnectionMode ConnectionMode
|
||||||
|
}
|
||||||
|
|
||||||
|
type UserInfo_ADCOnly struct {
|
||||||
|
SharedFiles uint64
|
||||||
|
UploadSpeedBps uint64
|
||||||
|
DownloadSpeedBps uint64
|
||||||
|
IsBot bool
|
||||||
|
IsRegistered bool
|
||||||
|
IsSuperUser bool
|
||||||
|
IsHubOwner bool
|
||||||
|
IPv4Address string // Passive <==> these fields are not set
|
||||||
|
IPv6Address string
|
||||||
|
IPv4UDPPort uint
|
||||||
|
IPv6UDPPort uint
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewUserInfo(username string) *UserInfo {
|
func NewUserInfo(username string) *UserInfo {
|
||||||
return &UserInfo{
|
return &UserInfo{
|
||||||
Nick: username,
|
Nick: username,
|
||||||
ConnectionMode: CONNECTIONMODE_PASSIVE,
|
|
||||||
HubsUnregistered: 1,
|
HubsUnregistered: 1,
|
||||||
|
UserInfo_NMDCOnly: UserInfo_NMDCOnly{
|
||||||
|
ConnectionMode: CONNECTIONMODE_PASSIVE,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user