Browse Source

Fix some issues, add RPL_WHOISACCOUNT

tags/v0.11.0-alpha
Daniel Oaks 6 years ago
parent
commit
0d5327de8a
3 changed files with 19 additions and 5 deletions
  1. 9
    2
      irc/client.go
  2. 1
    0
      irc/numerics.go
  3. 9
    3
      irc/server.go

+ 9
- 2
irc/client.go View File

@@ -322,10 +322,17 @@ func (client *Client) TryResume() {
322 322
 	timestamp := client.resumeDetails.Timestamp
323 323
 	var timestampString string
324 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 336
 	if oldClient == nil {
330 337
 		client.Send(nil, server.name, ERR_CANNOT_RESUME, oldnick, "Cannot resume connection, old client not found")
331 338
 		return

+ 1
- 0
irc/numerics.go View File

@@ -69,6 +69,7 @@ const (
69 69
 	RPL_CHANNELMODEIS               = "324"
70 70
 	RPL_UNIQOPIS                    = "325"
71 71
 	RPL_CHANNELCREATED              = "329"
72
+	RPL_WHOISACCOUNT                = "330"
72 73
 	RPL_NOTOPIC                     = "331"
73 74
 	RPL_TOPIC                       = "332"
74 75
 	RPL_TOPICTIME                   = "333"

+ 9
- 3
irc/server.go View File

@@ -1002,6 +1002,10 @@ func (client *Client) getWhoisOf(target *Client) {
1002 1002
 	if target.flags[TLS] {
1003 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 1009
 	if target.flags[Bot] {
1006 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,8 +2097,10 @@ func resumeHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
2093 2097
 
2094 2098
 	var timestamp *time.Time
2095 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 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,7 +2110,7 @@ func resumeHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
2104 2110
 		Timestamp: timestamp,
2105 2111
 	}
2106 2112
 
2107
-	return true
2113
+	return false
2108 2114
 }
2109 2115
 
2110 2116
 // USERHOST <nickname> [<nickname> <nickname> ...]

Loading…
Cancel
Save