Преглед изворни кода

Fix some issues, add RPL_WHOISACCOUNT

tags/v0.11.0-alpha
Daniel Oaks пре 6 година
родитељ
комит
0d5327de8a
3 измењених фајлова са 19 додато и 5 уклоњено
  1. 9
    2
      irc/client.go
  2. 1
    0
      irc/numerics.go
  3. 9
    3
      irc/server.go

+ 9
- 2
irc/client.go Прегледај датотеку

322
 	timestamp := client.resumeDetails.Timestamp
322
 	timestamp := client.resumeDetails.Timestamp
323
 	var timestampString string
323
 	var timestampString string
324
 	if timestamp != nil {
324
 	if timestamp != nil {
325
-		timestampString := timestamp.UTC().Format("2006-01-02T15:04:05.999Z")
325
+		timestampString = timestamp.UTC().Format("2006-01-02T15:04:05.999Z")
326
 	}
326
 	}
327
 
327
 
328
-	oldClient := server.clients.Get(oldnick)
328
+	// can't use server.clients.Get since we hold server.clients' tier 1 mutex
329
+	casefoldedName, err := CasefoldName(oldnick)
330
+	if err != nil {
331
+		client.Send(nil, server.name, ERR_CANNOT_RESUME, oldnick, "Cannot resume connection, old client not found")
332
+		return
333
+	}
334
+
335
+	oldClient := server.clients.byNick[casefoldedName]
329
 	if oldClient == nil {
336
 	if oldClient == nil {
330
 		client.Send(nil, server.name, ERR_CANNOT_RESUME, oldnick, "Cannot resume connection, old client not found")
337
 		client.Send(nil, server.name, ERR_CANNOT_RESUME, oldnick, "Cannot resume connection, old client not found")
331
 		return
338
 		return

+ 1
- 0
irc/numerics.go Прегледај датотеку

69
 	RPL_CHANNELMODEIS               = "324"
69
 	RPL_CHANNELMODEIS               = "324"
70
 	RPL_UNIQOPIS                    = "325"
70
 	RPL_UNIQOPIS                    = "325"
71
 	RPL_CHANNELCREATED              = "329"
71
 	RPL_CHANNELCREATED              = "329"
72
+	RPL_WHOISACCOUNT                = "330"
72
 	RPL_NOTOPIC                     = "331"
73
 	RPL_NOTOPIC                     = "331"
73
 	RPL_TOPIC                       = "332"
74
 	RPL_TOPIC                       = "332"
74
 	RPL_TOPICTIME                   = "333"
75
 	RPL_TOPICTIME                   = "333"

+ 9
- 3
irc/server.go Прегледај датотеку

1002
 	if target.flags[TLS] {
1002
 	if target.flags[TLS] {
1003
 		client.Send(nil, client.server.name, RPL_WHOISSECURE, client.nick, target.nick, "is using a secure connection")
1003
 		client.Send(nil, client.server.name, RPL_WHOISSECURE, client.nick, target.nick, "is using a secure connection")
1004
 	}
1004
 	}
1005
+	accountName := target.AccountName()
1006
+	if accountName != "" {
1007
+		client.Send(nil, client.server.name, RPL_WHOISACCOUNT, client.nick, accountName, "is logged in as")
1008
+	}
1005
 	if target.flags[Bot] {
1009
 	if target.flags[Bot] {
1006
 		client.Send(nil, client.server.name, RPL_WHOISBOT, client.nick, target.nick, ircfmt.Unescape("is a $bBot$b on ")+client.server.networkName)
1010
 		client.Send(nil, client.server.name, RPL_WHOISBOT, client.nick, target.nick, ircfmt.Unescape("is a $bBot$b on ")+client.server.networkName)
1007
 	}
1011
 	}
2093
 
2097
 
2094
 	var timestamp *time.Time
2098
 	var timestamp *time.Time
2095
 	if 1 < len(msg.Params) {
2099
 	if 1 < len(msg.Params) {
2096
-		timestamp, err = time.Parse("2006-01-02T15:04:05.999Z", msg.Params[1])
2097
-		if err != nil {
2100
+		ts, err := time.Parse("2006-01-02T15:04:05.999Z", msg.Params[1])
2101
+		if err == nil {
2102
+			timestamp = &ts
2103
+		} else {
2098
 			client.Send(nil, server.name, ERR_CANNOT_RESUME, oldnick, "Timestamp is not in 2006-01-02T15:04:05.999Z format, ignoring it")
2104
 			client.Send(nil, server.name, ERR_CANNOT_RESUME, oldnick, "Timestamp is not in 2006-01-02T15:04:05.999Z format, ignoring it")
2099
 		}
2105
 		}
2100
 	}
2106
 	}
2104
 		Timestamp: timestamp,
2110
 		Timestamp: timestamp,
2105
 	}
2111
 	}
2106
 
2112
 
2107
-	return true
2113
+	return false
2108
 }
2114
 }
2109
 
2115
 
2110
 // USERHOST <nickname> [<nickname> <nickname> ...]
2116
 // USERHOST <nickname> [<nickname> <nickname> ...]

Loading…
Откажи
Сачувај