From 307adba8bd2ebc2d38bb4ec89260a1c50432db66 Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Mon, 7 Sep 2020 05:59:31 -0400 Subject: [PATCH] fix #1213 --- conventional.yaml | 4 ++++ default.yaml | 4 ++++ irc/client.go | 7 +++++-- irc/config.go | 5 +++++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/conventional.yaml b/conventional.yaml index a0e688b5..d0a01274 100644 --- a/conventional.yaml +++ b/conventional.yaml @@ -127,6 +127,10 @@ server: # use ident protocol to get usernames check-ident: true + # ignore the supplied user/ident string from the USER command; always set the value to + # `~user` (literally) instead. this can potentially reduce confusion and simplify bans. + suppress-ident: false + # password to login to the server # generated using "oragono genpasswd" #password: "" diff --git a/default.yaml b/default.yaml index e4b2bb83..c2591b47 100644 --- a/default.yaml +++ b/default.yaml @@ -154,6 +154,10 @@ server: # use ident protocol to get usernames check-ident: false + # ignore the supplied user/ident string from the USER command; always set the value to + # `~user` (literally) instead. this can potentially reduce confusion and simplify bans. + suppress-ident: false + # password to login to the server # generated using "oragono genpasswd" #password: "" diff --git a/irc/client.go b/irc/client.go index 3d9945aa..ab24c6b7 100644 --- a/irc/client.go +++ b/irc/client.go @@ -1083,7 +1083,8 @@ func (client *Client) IdleSeconds() uint64 { // SetNames sets the client's ident and realname. func (client *Client) SetNames(username, realname string, fromIdent bool) error { - limit := client.server.Config().Limits.IdentLen + config := client.server.Config() + limit := config.Limits.IdentLen if !fromIdent { limit -= 1 // leave room for the prepended ~ } @@ -1095,7 +1096,9 @@ func (client *Client) SetNames(username, realname string, fromIdent bool) error return errInvalidUsername } - if !fromIdent { + if config.Server.SuppressIdent { + username = "~user" + } else if !fromIdent { username = "~" + username } diff --git a/irc/config.go b/irc/config.go index d2fb4a44..d35af21f 100644 --- a/irc/config.go +++ b/irc/config.go @@ -498,6 +498,7 @@ type Config struct { lookupHostnames bool ForwardConfirmHostnames bool `yaml:"forward-confirm-hostnames"` CheckIdent bool `yaml:"check-ident"` + SuppressIdent bool `yaml:"suppress-ident"` MOTD string motdLines []string MOTDFormatting bool `yaml:"motd-formatting"` @@ -896,6 +897,10 @@ func LoadConfig(filename string) (config *Config, err error) { } } + if config.Server.CheckIdent && config.Server.SuppressIdent { + return nil, errors.New("Can't configure both check-ident and suppress-ident") + } + config.Server.supportedCaps = caps.NewCompleteSet() config.Server.capValues = make(caps.Values)