From 57e21877420bb916d167ff807cce9f950f230815 Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Sun, 26 Apr 2020 02:19:10 -0400 Subject: [PATCH] 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