move some UserInfo properties into separate adc/nmdc sub structs
--HG-- branch : adc
This commit is contained in:
parent
95cd5c85f0
commit
aabaa128c4
@ -24,23 +24,27 @@ func TestMyINFOParse(t *testing.T) {
|
||||
ClientVersion: "1.4.3",
|
||||
Email: "xyz@example.com",
|
||||
ShareSize: 53054999578,
|
||||
ConnectionMode: CONNECTIONMODE_PASSIVE,
|
||||
Flag: FLAG_NORMAL,
|
||||
Slots: 1,
|
||||
Speed: "0.0",
|
||||
HubsUnregistered: 9,
|
||||
HubsRegistered: 0,
|
||||
HubsOperator: 2,
|
||||
UserInfo_NMDCOnly: UserInfo_NMDCOnly{
|
||||
ConnectionMode: CONNECTIONMODE_PASSIVE,
|
||||
Speed: "0.0",
|
||||
},
|
||||
},
|
||||
},
|
||||
myInfoTestPair{
|
||||
in: "$ALL ixxxxxxx0 $P$10A$$0$",
|
||||
expect: UserInfo{
|
||||
Nick: "ixxxxxxx0",
|
||||
ClientVersion: "0", // Auto-inserted by the parser for short-format MyINFO strings
|
||||
ConnectionMode: CONNECTIONMODE_PASSIVE,
|
||||
Flag: UserFlag(rune('A')),
|
||||
Speed: "1",
|
||||
Nick: "ixxxxxxx0",
|
||||
ClientVersion: "0", // Auto-inserted by the parser for short-format MyINFO strings
|
||||
Flag: UserFlag(rune('A')),
|
||||
UserInfo_NMDCOnly: UserInfo_NMDCOnly{
|
||||
ConnectionMode: CONNECTIONMODE_PASSIVE,
|
||||
Speed: "1",
|
||||
},
|
||||
},
|
||||
},
|
||||
myInfoTestPair{
|
||||
@ -49,11 +53,13 @@ func TestMyINFOParse(t *testing.T) {
|
||||
Nick: "SXXXX_XXXXXXR",
|
||||
ClientTag: "ncdc",
|
||||
ClientVersion: "1.19.1-12-g5561",
|
||||
ConnectionMode: CONNECTIONMODE_PASSIVE,
|
||||
Flag: UserFlag(rune('Q')),
|
||||
Slots: 10,
|
||||
Speed: "0.00",
|
||||
HubsUnregistered: 1,
|
||||
UserInfo_NMDCOnly: UserInfo_NMDCOnly{
|
||||
ConnectionMode: CONNECTIONMODE_PASSIVE,
|
||||
Speed: "0.00",
|
||||
},
|
||||
},
|
||||
},
|
||||
myInfoTestPair{
|
||||
@ -63,10 +69,12 @@ func TestMyINFOParse(t *testing.T) {
|
||||
Description: "desccccc",
|
||||
ClientTag: "HexChat",
|
||||
ClientVersion: "2.12.1",
|
||||
ConnectionMode: CONNECTIONMODE_PASSIVE,
|
||||
Flag: UserFlag(rune('p')),
|
||||
HubsUnregistered: 1,
|
||||
Slots: 0,
|
||||
UserInfo_NMDCOnly: UserInfo_NMDCOnly{
|
||||
ConnectionMode: CONNECTIONMODE_PASSIVE,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
30
UserInfo.go
30
UserInfo.go
@ -8,21 +8,43 @@ type UserInfo struct {
|
||||
ClientVersion string
|
||||
Email string
|
||||
ShareSize uint64
|
||||
ConnectionMode ConnectionMode
|
||||
Flag UserFlag
|
||||
Slots uint64
|
||||
Speed string
|
||||
HubsUnregistered uint64
|
||||
HubsRegistered uint64
|
||||
HubsOperator uint64
|
||||
IsOperator bool
|
||||
IPAddress string
|
||||
|
||||
UserInfo_NMDCOnly
|
||||
UserInfo_ADCOnly
|
||||
}
|
||||
|
||||
type UserInfo_NMDCOnly struct {
|
||||
Speed 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 {
|
||||
return &UserInfo{
|
||||
Nick: username,
|
||||
ConnectionMode: CONNECTIONMODE_PASSIVE,
|
||||
HubsUnregistered: 1,
|
||||
UserInfo_NMDCOnly: UserInfo_NMDCOnly{
|
||||
ConnectionMode: CONNECTIONMODE_PASSIVE,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user