Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 21847db9fd | |||
| b8122710f5 | |||
| f8c0fc54d8 | |||
| 4490444d1c | |||
| c5f655ff78 | |||
| 4415109174 | |||
| 0adc13ddfa | |||
| 59c56fea1b | |||
| 7f8f98aa5a | |||
| 8536cb0a5c | |||
| 553ec20850 | |||
| a403dac461 | |||
| 59a37b975c | |||
| a4e7d876cc |
2
.hgtags
2
.hgtags
@@ -14,3 +14,5 @@ b0e57a5fcffdf4102d669db51a3648ddf66a0792 libnmdc-r8
|
||||
e7c2c71ef24b386add728fad35fff4a996fccbac libnmdc-r9
|
||||
3ecc037cf2d7080572fe87c2e39ecd153fb0e947 libnmdc-r10
|
||||
5149ffe70ea8475e480b682345b31aa45a3352db release-0.11
|
||||
22b156a6fc2f6161765317f4ec9ab3731a26e0e2 release-0.12
|
||||
3ee0f4ea5142d66079a9500bdcd48a53bdcf362f release-0.13
|
||||
|
||||
@@ -28,6 +28,8 @@ type HubConnection struct {
|
||||
connValid bool
|
||||
sentOurHello bool
|
||||
autoReconnect bool
|
||||
|
||||
supports map[string]struct{}
|
||||
}
|
||||
|
||||
// Thread-safe user accessor.
|
||||
@@ -85,6 +87,8 @@ func (this *HubConnection) userJoined_Full(uinf *UserInfo) {
|
||||
|
||||
if !userExisted {
|
||||
this.processEvent(HubEvent{EventType: EVENT_USER_JOINED, Nick: uinf.Nick})
|
||||
} else {
|
||||
this.processEvent(HubEvent{EventType: EVENT_USER_UPDATED_INFO, Nick: uinf.Nick})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,9 +135,8 @@ func (this *HubConnection) processProtocolMessage(message string) {
|
||||
switch commandParts[0] {
|
||||
|
||||
case "$Lock":
|
||||
this.SayRaw("$Supports NoGetINFO UserCommand UserIP2|" +
|
||||
"$Key " + unlock([]byte(commandParts[1])) + "|" +
|
||||
"$ValidateNick " + Escape(this.Hco.Self.Nick) + "|")
|
||||
this.SayRaw("$Supports NoHello NoGetINFO UserCommand UserIP2 QuickList ChatOnly|" +
|
||||
"$Key " + unlock([]byte(commandParts[1])) + "|")
|
||||
this.sentOurHello = false
|
||||
|
||||
case "$Hello":
|
||||
@@ -185,12 +188,13 @@ func (this *HubConnection) processProtocolMessage(message string) {
|
||||
case "$MyINFO":
|
||||
u := UserInfo{}
|
||||
err := u.fromMyINFO(commandParts[1])
|
||||
if err == nil {
|
||||
this.userJoined_Full(&u)
|
||||
} else {
|
||||
if err != nil {
|
||||
this.processEvent(HubEvent{EventType: EVENT_DEBUG_MESSAGE, Message: err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
this.userJoined_Full(&u)
|
||||
|
||||
case "$NickList":
|
||||
nicklist := strings.Split(commandParts[1], "$$")
|
||||
for _, nick := range nicklist {
|
||||
@@ -241,11 +245,39 @@ func (this *HubConnection) processProtocolMessage(message string) {
|
||||
}
|
||||
|
||||
case "$UserIP":
|
||||
// Final message in PtokaX connection handshake - trigger connection callback.
|
||||
// This might not be the case for other hubsofts, though
|
||||
if this.State != CONNECTIONSTATE_CONNECTED {
|
||||
this.processEvent(HubEvent{EventType: EVENT_CONNECTION_STATE_CHANGED, StateChange: CONNECTIONSTATE_CONNECTED})
|
||||
this.State = CONNECTIONSTATE_CONNECTED
|
||||
this.userLock.Lock()
|
||||
|
||||
pairs := strings.Split(commandParts[1], "$$")
|
||||
notifyOfUpdate := make([]string, 0, len(pairs))
|
||||
|
||||
nextIPPair:
|
||||
for _, pair := range pairs {
|
||||
parts := strings.SplitN(pair, " ", 2)
|
||||
if len(parts) != 2 {
|
||||
// ????
|
||||
continue nextIPPair
|
||||
}
|
||||
|
||||
ip2nick := parts[0]
|
||||
ip2addr := parts[1]
|
||||
|
||||
uinfo, ok := this.users[ip2nick]
|
||||
if !ok {
|
||||
this.processEvent(HubEvent{EventType: EVENT_DEBUG_MESSAGE, Message: "Recieved IP '" + ip2addr + "' for unknown user '" + ip2nick + "'"})
|
||||
continue nextIPPair
|
||||
}
|
||||
|
||||
if uinfo.IPAddress != ip2addr {
|
||||
uinfo.IPAddress = ip2addr
|
||||
notifyOfUpdate = append(notifyOfUpdate, ip2nick)
|
||||
this.users[ip2nick] = uinfo
|
||||
}
|
||||
}
|
||||
|
||||
this.userLock.Unlock()
|
||||
|
||||
for _, nick := range notifyOfUpdate {
|
||||
this.processEvent(HubEvent{EventType: EVENT_USER_UPDATED_INFO, Nick: nick})
|
||||
}
|
||||
|
||||
case "$ForceMove":
|
||||
@@ -273,8 +305,34 @@ func (this *HubConnection) processProtocolMessage(message string) {
|
||||
this.processEvent(HubEvent{EventType: EVENT_DEBUG_MESSAGE, Message: "Malformed usercommand '" + commandParts[1] + "'"})
|
||||
}
|
||||
|
||||
// IGNORABLE COMMANDS
|
||||
case "$Supports":
|
||||
this.supports = make(map[string]struct{})
|
||||
for _, s := range strings.Split(commandParts[1], " ") {
|
||||
this.supports[s] = struct{}{}
|
||||
}
|
||||
|
||||
if !this.sentOurHello {
|
||||
|
||||
// Need to log in.
|
||||
// If the hub supports QuickList, we can skip one network roundtrip
|
||||
if _, ok := this.supports["QuickList"]; ok {
|
||||
this.SayInfo()
|
||||
this.SayRaw("$GetNickList|")
|
||||
} else {
|
||||
this.SayRaw("$ValidateNick " + Escape(this.Hco.Self.Nick) + "|")
|
||||
}
|
||||
|
||||
// This also counts as the end of the handshake from our POV. Consider
|
||||
// ourselves logged in
|
||||
this.sentOurHello = true
|
||||
if this.State != CONNECTIONSTATE_CONNECTED {
|
||||
this.processEvent(HubEvent{EventType: EVENT_CONNECTION_STATE_CHANGED, StateChange: CONNECTIONSTATE_CONNECTED})
|
||||
this.State = CONNECTIONSTATE_CONNECTED
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// IGNORABLE COMMANDS
|
||||
case "$HubTopic":
|
||||
case "$Search":
|
||||
case "$ConnectToMe":
|
||||
|
||||
@@ -24,6 +24,7 @@ type UserInfo struct {
|
||||
HubsRegistered uint64
|
||||
HubsOperator uint64
|
||||
IsOperator bool
|
||||
IPAddress string
|
||||
}
|
||||
|
||||
var rx_myinfo *regexp.Regexp
|
||||
|
||||
@@ -9,6 +9,16 @@ Tags: nmdc
|
||||
|
||||
=CHANGELOG=
|
||||
|
||||
2017-02-09 0.14
|
||||
- Fix an issue with crashing on malformed IP addresses supplied by the hub
|
||||
|
||||
2017-02-09 0.13
|
||||
- Feature: Implement UserIP2 extension, to retrieve IP addresses of other users
|
||||
- Enhancement: Implement QuickList extension (reduce one network roundtrip during initial connection)
|
||||
- Enhancement: Implement NoHello extension (faster connection performance)
|
||||
- Enhancement: Implement ChatOnly extension
|
||||
- Fix an issue with not notifying client on all MyINFO updates
|
||||
|
||||
2017-02-05 0.12
|
||||
- Fix an issue with mutex deadlock when accessing user information from a callback
|
||||
- Fix an issue with silent disconnection if a password was required but not present
|
||||
|
||||
Reference in New Issue
Block a user