From 521d5bf50f44707d005ef092229e56a8e52b6319 Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Wed, 29 May 2019 14:24:23 -0400 Subject: [PATCH 1/2] fix #380 Partially fixed earlier in #467 --- docs/MANUAL.md | 2 +- irc/handlers.go | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/docs/MANUAL.md b/docs/MANUAL.md index 6b944974..178813cf 100644 --- a/docs/MANUAL.md +++ b/docs/MANUAL.md @@ -476,7 +476,7 @@ To unset this mode: ### +s - Secret -If this mode is set, it means that your channel should be marked as 'secret'. Your channel won't show up in `/LIST` or `/WHOIS`. +If this mode is set, it means that your channel should be marked as 'secret'. Your channel won't show up in `/LIST` or `/WHOIS`, and non-members won't be able to see its members with `/NAMES` or `/WHO`. To set this mode: diff --git a/irc/handlers.go b/irc/handlers.go index d2d50c34..a929594a 100644 --- a/irc/handlers.go +++ b/irc/handlers.go @@ -1954,17 +1954,20 @@ func namesHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Res // TODO: in a post-federation world, process `target` (server to forward request to) if len(channels) == 0 { - for _, channel := range server.channels.Channels() { - channel.Names(client, rb) - } + rb.Add(nil, server.name, RPL_ENDOFNAMES, client.Nick(), "*", client.t("End of NAMES list")) return false } for _, chname := range channels { + success := false channel := server.channels.Get(chname) if channel != nil { - channel.Names(client, rb) - } else if chname != "" { + if !channel.flags.HasMode(modes.Secret) || channel.hasClient(client) || client.HasMode(modes.Operator) { + channel.Names(client, rb) + success = true + } + } + if !success { // channel.Names() sends this numeric itself on success rb.Add(nil, server.name, RPL_ENDOFNAMES, client.Nick(), chname, client.t("End of NAMES list")) } } From 364d31e10ce95d9f6f3a0b39d28bcfd2b8f574f1 Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Wed, 29 May 2019 14:51:09 -0400 Subject: [PATCH 2/2] implement the strict modern behavior --- irc/handlers.go | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/irc/handlers.go b/irc/handlers.go index a929594a..0f5b3898 100644 --- a/irc/handlers.go +++ b/irc/handlers.go @@ -1953,24 +1953,28 @@ func namesHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Res // TODO: in a post-federation world, process `target` (server to forward request to) + // implement the modern behavior: https://modern.ircdocs.horse/#names-message + // "Servers MAY only return information about the first and silently ignore the others." + // "If no parameter is given for this command, servers SHOULD return one RPL_ENDOFNAMES numeric + // with the parameter set to an asterix character" + if len(channels) == 0 { rb.Add(nil, server.name, RPL_ENDOFNAMES, client.Nick(), "*", client.t("End of NAMES list")) return false } - for _, chname := range channels { - success := false - channel := server.channels.Get(chname) - if channel != nil { - if !channel.flags.HasMode(modes.Secret) || channel.hasClient(client) || client.HasMode(modes.Operator) { - channel.Names(client, rb) - success = true - } - } - if !success { // channel.Names() sends this numeric itself on success - rb.Add(nil, server.name, RPL_ENDOFNAMES, client.Nick(), chname, client.t("End of NAMES list")) + chname := channels[0] + success := false + channel := server.channels.Get(chname) + if channel != nil { + if !channel.flags.HasMode(modes.Secret) || channel.hasClient(client) || client.HasMode(modes.Operator) { + channel.Names(client, rb) + success = true } } + if !success { // channel.Names() sends this numeric itself on success + rb.Add(nil, server.name, RPL_ENDOFNAMES, client.Nick(), chname, client.t("End of NAMES list")) + } return false }