Browse Source

fix #1366

Include an 'r' flag in RPL_WHOREPLY for registered nicks
tags/v2.4.0-rc1
Shivaram Lingamneni 3 years ago
parent
commit
6513136ea3
1 changed files with 14 additions and 3 deletions
  1. 14
    3
      irc/handlers.go

+ 14
- 3
irc/handlers.go View File

@@ -3049,7 +3049,7 @@ func (fields whoxFields) Has(field rune) bool {
3049 3049
 // <channel> <user> <host> <server> <nick> <H|G>[*][~|&|@|%|+][B] :<hopcount> <real name>
3050 3050
 // whox format:
3051 3051
 // <type> <channel> <user> <ip> <host> <server> <nick> <H|G>[*][~|&|@|%|+][B] <hops> <idle> <account> <rank> :<real name>
3052
-func (client *Client) rplWhoReply(channel *Channel, target *Client, rb *ResponseBuffer, hasPrivs, isWhox bool, fields whoxFields, whoType string) {
3052
+func (client *Client) rplWhoReply(channel *Channel, target *Client, rb *ResponseBuffer, hasPrivs, includeRFlag, isWhox bool, fields whoxFields, whoType string) {
3053 3053
 	params := []string{client.Nick()}
3054 3054
 
3055 3055
 	details := target.Details()
@@ -3104,6 +3104,10 @@ func (client *Client) rplWhoReply(channel *Channel, target *Client, rb *Response
3104 3104
 			flags.WriteRune('B')
3105 3105
 		}
3106 3106
 
3107
+		if includeRFlag && details.account != "" {
3108
+			flags.WriteRune('r')
3109
+		}
3110
+
3107 3111
 		params = append(params, flags.String())
3108 3112
 
3109 3113
 	}
@@ -3157,6 +3161,13 @@ func whoHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Respo
3157 3161
 		return false
3158 3162
 	}
3159 3163
 
3164
+	// include the r flag only if nick and account are synonymous
3165
+	config := server.Config()
3166
+	includeRFlag := config.Accounts.NickReservation.Enabled &&
3167
+		config.Accounts.NickReservation.Method == NickEnforcementStrict &&
3168
+		!config.Accounts.NickReservation.AllowCustomEnforcement &&
3169
+		config.Accounts.NickReservation.ForceNickEqualsAccount
3170
+
3160 3171
 	sFields := "cuhsnf"
3161 3172
 	whoType := "0"
3162 3173
 	isWhox := false
@@ -3200,7 +3211,7 @@ func whoHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Respo
3200 3211
 				}
3201 3212
 				for _, member := range members {
3202 3213
 					if !member.HasMode(modes.Invisible) || isJoined || isOper {
3203
-						client.rplWhoReply(channel, member, rb, isOper, isWhox, fields, whoType)
3214
+						client.rplWhoReply(channel, member, rb, isOper, includeRFlag, isWhox, fields, whoType)
3204 3215
 					}
3205 3216
 				}
3206 3217
 			}
@@ -3231,7 +3242,7 @@ func whoHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Respo
3231 3242
 
3232 3243
 		for mclient := range server.clients.FindAll(mask) {
3233 3244
 			if isOper || !mclient.HasMode(modes.Invisible) || isFriend(mclient) {
3234
-				client.rplWhoReply(nil, mclient, rb, isOper, isWhox, fields, whoType)
3245
+				client.rplWhoReply(nil, mclient, rb, isOper, includeRFlag, isWhox, fields, whoType)
3235 3246
 			}
3236 3247
 		}
3237 3248
 	}

Loading…
Cancel
Save