4 Commits

Author SHA1 Message Date
756b347592 readme 2016-05-10 19:18:04 +12:00
d4e442bd84 separate ClientTag and ClientVersion in UserInfo 2016-05-09 18:13:38 +12:00
bbdc18698d changelog 2016-05-08 14:46:41 +12:00
b049acad90 Added tag libnmdc-r7 for changeset 71343a2c641a 2016-05-08 14:44:45 +12:00
3 changed files with 28 additions and 11 deletions

View File

@@ -9,3 +9,4 @@ da9f123633f9c28be6435ed7898139665d4c39d9 nmdc-log-service-1.0.2
4116422bb10229d887f9296970a166fa1ef8c5fd nmdc-log-service-1.0.3 4116422bb10229d887f9296970a166fa1ef8c5fd nmdc-log-service-1.0.3
cb86f3a40115cc46f450c0c83fd9b9d3b740e820 nmdc-log-service-1.0.4 cb86f3a40115cc46f450c0c83fd9b9d3b740e820 nmdc-log-service-1.0.4
cb86f3a40115cc46f450c0c83fd9b9d3b740e820 libnmdc-r6 cb86f3a40115cc46f450c0c83fd9b9d3b740e820 libnmdc-r6
71343a2c641a438206d30ea7e75dc89a11dbef00 libnmdc-r7

View File

@@ -6,6 +6,7 @@ import (
"fmt" "fmt"
"regexp" "regexp"
"strconv" "strconv"
"strings"
) )
type UserFlag byte type UserFlag byte
@@ -37,6 +38,7 @@ type UserInfo struct {
Nick string Nick string
Description string Description string
ClientTag string ClientTag string
ClientVersion string
Email string Email string
ShareSize uint64 ShareSize uint64
ConnectionMode ConnectionMode ConnectionMode ConnectionMode
@@ -54,7 +56,7 @@ var rx_myinfo_notag *regexp.Regexp
func init() { func init() {
// $ALL <nick> <description>$ $<connection><flag>$<e-mail>$<sharesize>$ // $ALL <nick> <description>$ $<connection><flag>$<e-mail>$<sharesize>$
rx_myinfo = regexp.MustCompile("(?ms)^\\$ALL ([^ ]+) ([^<]*)<([^,]*),M:(.),H:([0-9]+)/([0-9]+)/([0-9]+),S:([0-9]+)>\\$.\\$(.+?)(.)\\$([^$]*)\\$([0-9]*)\\$$") rx_myinfo = regexp.MustCompile("(?ms)^\\$ALL ([^ ]+) ([^<]*)<([^,]*)V:([^,]+),M:(.),H:([0-9]+)/([0-9]+)/([0-9]+),S:([0-9]+)>\\$.\\$(.+?)(.)\\$([^$]*)\\$([0-9]*)\\$$")
rx_myinfo_notag = regexp.MustCompile("(?ms)^\\$ALL ([^ ]+) ([^$]*)\\$.\\$(.*)(.)\\$([^$]*)\\$([0-9]*)\\$$") // Fallback for no tag rx_myinfo_notag = regexp.MustCompile("(?ms)^\\$ALL ([^ ]+) ([^$]*)\\$.\\$(.*)(.)\\$([^$]*)\\$([0-9]*)\\$$") // Fallback for no tag
/* /*
@@ -91,21 +93,22 @@ func maybeParse(str string, dest *uint64, default_val uint64) {
} }
func (this *UserInfo) fromMyINFO(protomsg string) error { func (this *UserInfo) fromMyINFO(protomsg string) error {
// Normal format (with tag in exact M/H/S order) // Normal format (with tag in exact V/M/H/S order)
matches := rx_myinfo.FindStringSubmatch(protomsg) matches := rx_myinfo.FindStringSubmatch(protomsg)
if matches != nil { if matches != nil {
this.Nick = matches[1] this.Nick = matches[1]
this.Description = NMDCUnescape(matches[2]) this.Description = NMDCUnescape(matches[2])
this.ClientTag = NMDCUnescape(matches[3]) this.ClientTag = NMDCUnescape(matches[3])
this.ClientVersion = matches[4]
this.ConnectionMode = ConnectionMode(matches[4][0]) this.ConnectionMode = ConnectionMode(matches[4][0])
maybeParse(matches[5], &this.HubsUnregistered, 0) maybeParse(matches[6], &this.HubsUnregistered, 0)
maybeParse(matches[6], &this.HubsRegistered, 0) maybeParse(matches[7], &this.HubsRegistered, 0)
maybeParse(matches[7], &this.HubsOperator, 0) maybeParse(matches[8], &this.HubsOperator, 0)
maybeParse(matches[8], &this.Slots, 0) maybeParse(matches[9], &this.Slots, 0)
this.Speed = matches[9] this.Speed = matches[10]
this.Flag = UserFlag(matches[10][0]) this.Flag = UserFlag(matches[11][0])
this.Email = NMDCUnescape(matches[11]) this.Email = NMDCUnescape(matches[12])
maybeParse(matches[12], &this.ShareSize, 0) maybeParse(matches[13], &this.ShareSize, 0)
return nil return nil
} }
@@ -116,6 +119,7 @@ func (this *UserInfo) fromMyINFO(protomsg string) error {
this.Nick = matches[1] this.Nick = matches[1]
this.Description = NMDCUnescape(matches[2]) this.Description = NMDCUnescape(matches[2])
this.ClientTag = "" this.ClientTag = ""
this.ClientVersion = "0"
this.ConnectionMode = CONNECTIONMODE_PASSIVE this.ConnectionMode = CONNECTIONMODE_PASSIVE
this.HubsUnregistered = 0 this.HubsUnregistered = 0
this.HubsRegistered = 0 this.HubsRegistered = 0
@@ -136,10 +140,11 @@ func (this *UserInfo) fromMyINFO(protomsg string) error {
// Returns the MyINFO command, WITH leading $MyINFO, and WITHOUT trailing pipe // Returns the MyINFO command, WITH leading $MyINFO, and WITHOUT trailing pipe
func (this *UserInfo) toMyINFO() string { func (this *UserInfo) toMyINFO() string {
return fmt.Sprintf( return fmt.Sprintf(
"$MyINFO $ALL %s %s<%s,M:%c,H:%d/%d/%d,S:%d>$ $%s%c$%s$%d$", "$MyINFO $ALL %s %s<%s V:%s,M:%c,H:%d/%d/%d,S:%d>$ $%s%c$%s$%d$",
this.Nick, this.Nick,
this.Description, this.Description,
this.ClientTag, this.ClientTag,
strings.Replace(this.ClientVersion, ",", "-", -1), // just in case
this.ConnectionMode, this.ConnectionMode,
this.HubsUnregistered, this.HubsUnregistered,
this.HubsRegistered, this.HubsRegistered,

View File

@@ -9,6 +9,17 @@ Tags: nmdc
=CHANGELOG= =CHANGELOG=
2016-05-10 r8
- Enhancement: Separate `ClientTag` and `ClientVersion` in `UserInfo` structs
2016-05-08 r7
- BREAKING: Remove direct access to `HubConnection.Users` map
- Feature: Threadsafe user map accessor
- Feature: Option to disable auto-reconnection
- Feature: New `Disconnect()`, `UserCount()`, `UserExists()` functions
- Enhancement: Support `$OpList`, add `IsOperator` member to `UserInfo` structs
- Refactor into multiple files
2016-04-16 r6 2016-04-16 r6
- Fix an issue with calling `panic()` on certain types of abnormal network failure - Fix an issue with calling `panic()` on certain types of abnormal network failure