From 57e21877420bb916d167ff807cce9f950f230815 Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Sun, 26 Apr 2020 02:19:10 -0400 Subject: [PATCH 1/4] fix #964 --- conventional.yaml | 4 ++++ irc/config.go | 1 + irc/handlers.go | 8 ++++++++ oragono.yaml | 4 ++++ 4 files changed, 17 insertions(+) diff --git a/conventional.yaml b/conventional.yaml index 0bba476a..5da77654 100644 --- a/conventional.yaml +++ b/conventional.yaml @@ -491,6 +491,10 @@ channels: # how many channels can each account register? max-channels-per-account: 15 + # as a crude countermeasure against spambots, connections younger than this value + # will get an empty response to /LIST (a time period of 0 disables) + list-delay: 0s + # operator classes oper-classes: # local operator diff --git a/irc/config.go b/irc/config.go index d2c20c58..42d58512 100644 --- a/irc/config.go +++ b/irc/config.go @@ -550,6 +550,7 @@ type Config struct { OperatorOnly bool `yaml:"operator-only"` MaxChannelsPerAccount int `yaml:"max-channels-per-account"` } + ListDelay time.Duration `yaml:"list-delay"` } OperClasses map[string]*OperClassConfig `yaml:"oper-classes"` diff --git a/irc/handlers.go b/irc/handlers.go index 86af4a1e..711df3a4 100644 --- a/irc/handlers.go +++ b/irc/handlers.go @@ -1408,6 +1408,14 @@ func languageHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb * // LIST [{,}] [{,}] func listHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool { + config := server.Config() + if time.Since(client.ctime) < config.Channels.ListDelay && client.Account() == "" { + remaining := time.Until(client.ctime.Add(config.Channels.ListDelay)) + csNotice(rb, fmt.Sprintf(client.t("This server requires that you wait %v after connecting before you can use /LIST. You have %v left."), config.Channels.ListDelay, remaining)) + rb.Add(nil, server.name, RPL_LISTEND, client.nick, client.t("End of LIST")) + return false + } + // get channels var channels []string for _, param := range msg.Params { diff --git a/oragono.yaml b/oragono.yaml index d53798b5..030d46db 100644 --- a/oragono.yaml +++ b/oragono.yaml @@ -512,6 +512,10 @@ channels: # how many channels can each account register? max-channels-per-account: 15 + # as a crude countermeasure against spambots, connections younger than this value + # will get an empty response to /LIST (a time period of 0 disables) + list-delay: 0s + # operator classes oper-classes: # local operator From 3e2138db4fa22db4de231dfcc8b53083ba6c8178 Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Sun, 26 Apr 2020 03:00:00 -0400 Subject: [PATCH 2/4] clarify that list-delay only applies to anonymous users --- conventional.yaml | 4 ++-- oragono.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/conventional.yaml b/conventional.yaml index 5da77654..e3929a83 100644 --- a/conventional.yaml +++ b/conventional.yaml @@ -491,8 +491,8 @@ channels: # how many channels can each account register? max-channels-per-account: 15 - # as a crude countermeasure against spambots, connections younger than this value - # will get an empty response to /LIST (a time period of 0 disables) + # as a crude countermeasure against spambots, anonymous connections younger + # than this value will get an empty response to /LIST (a time period of 0 disables) list-delay: 0s # operator classes diff --git a/oragono.yaml b/oragono.yaml index 030d46db..9ae504ab 100644 --- a/oragono.yaml +++ b/oragono.yaml @@ -512,8 +512,8 @@ channels: # how many channels can each account register? max-channels-per-account: 15 - # as a crude countermeasure against spambots, connections younger than this value - # will get an empty response to /LIST (a time period of 0 disables) + # as a crude countermeasure against spambots, anonymous connections younger + # than this value will get an empty response to /LIST (a time period of 0 disables) list-delay: 0s # operator classes From 5cdb81e1ea3be106469572f70adb8a2d2e58528d Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Sun, 26 Apr 2020 03:08:44 -0400 Subject: [PATCH 3/4] use Nick() --- irc/handlers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/irc/handlers.go b/irc/handlers.go index 711df3a4..2933cc50 100644 --- a/irc/handlers.go +++ b/irc/handlers.go @@ -1412,7 +1412,7 @@ func listHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Resp if time.Since(client.ctime) < config.Channels.ListDelay && client.Account() == "" { remaining := time.Until(client.ctime.Add(config.Channels.ListDelay)) csNotice(rb, fmt.Sprintf(client.t("This server requires that you wait %v after connecting before you can use /LIST. You have %v left."), config.Channels.ListDelay, remaining)) - rb.Add(nil, server.name, RPL_LISTEND, client.nick, client.t("End of LIST")) + rb.Add(nil, server.name, RPL_LISTEND, client.Nick(), client.t("End of LIST")) return false } From 3626958f1e998ef9c437c4aa7a10a28cfabdf1ff Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Mon, 27 Apr 2020 00:58:48 -0400 Subject: [PATCH 4/4] also exempt operators from LIST restrictions --- irc/handlers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/irc/handlers.go b/irc/handlers.go index 2933cc50..dbcb6793 100644 --- a/irc/handlers.go +++ b/irc/handlers.go @@ -1409,7 +1409,7 @@ func languageHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb * // LIST [{,}] [{,}] func listHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool { config := server.Config() - if time.Since(client.ctime) < config.Channels.ListDelay && client.Account() == "" { + if time.Since(client.ctime) < config.Channels.ListDelay && client.Account() == "" && !client.HasMode(modes.Operator) { remaining := time.Until(client.ctime.Add(config.Channels.ListDelay)) csNotice(rb, fmt.Sprintf(client.t("This server requires that you wait %v after connecting before you can use /LIST. You have %v left."), config.Channels.ListDelay, remaining)) rb.Add(nil, server.name, RPL_LISTEND, client.Nick(), client.t("End of LIST"))