diff --git a/irc/client.go b/irc/client.go index 462deeb8..a861f021 100644 --- a/irc/client.go +++ b/irc/client.go @@ -176,12 +176,12 @@ func NewClient(server *Server, conn net.Conn, isTLS bool) { client.Notice(client.t("*** Looking up your username")) resp, err := ident.Query(clientHost, serverPort, clientPort, IdentTimeoutSeconds) if err == nil { - username := resp.Identifier - cfusername, err := CasefoldName(username) - if err == nil { + ident := resp.Identifier[:config.Limits.IdentLen-1] + if isIdent(ident) { + identLower := strings.ToLower(ident) // idents can only be ASCII chars only client.Notice(client.t("*** Found your username")) - client.username = username - client.usernameCasefolded = cfusername + client.username = ident + client.usernameCasefolded = identLower // we don't need to updateNickMask here since nickMask is not used for anything yet } else { client.Notice(client.t("*** Got a malformed username, ignoring")) diff --git a/irc/config.go b/irc/config.go index c19bf157..41f49259 100644 --- a/irc/config.go +++ b/irc/config.go @@ -206,12 +206,13 @@ type Limits struct { AwayLen int `yaml:"awaylen"` ChanListModes int `yaml:"chan-list-modes"` ChannelLen int `yaml:"channellen"` + IdentLen int `yaml:"identlen"` KickLen int `yaml:"kicklen"` + LineLen LineLenLimits `yaml:"linelen"` MonitorEntries int `yaml:"monitor-entries"` NickLen int `yaml:"nicklen"` TopicLen int `yaml:"topiclen"` WhowasEntries int `yaml:"whowas-entries"` - LineLen LineLenLimits `yaml:"linelen"` } // STSConfig controls the STS configuration/ @@ -491,6 +492,10 @@ func LoadConfig(filename string) (config *Config, err error) { if len(config.Server.Listen) == 0 { return nil, ErrNoListenersDefined } + //dan: automagically fix identlen until a few releases in the future (from now, 0.12.0), being a newly-introduced limit + if config.Limits.IdentLen < 1 { + config.Limits.IdentLen = 10 + } if config.Limits.NickLen < 1 || config.Limits.ChannelLen < 2 || config.Limits.AwayLen < 1 || config.Limits.KickLen < 1 || config.Limits.TopicLen < 1 { return nil, ErrLimitsAreInsane } diff --git a/irc/handlers.go b/irc/handlers.go index e89fee37..8f941a35 100644 --- a/irc/handlers.go +++ b/irc/handlers.go @@ -2193,7 +2193,9 @@ func userHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Resp return false } - err := client.SetNames(msg.Params[0], msg.Params[3]) + ident := msg.Params[0][:server.Limits().IdentLen-1] // -1 as SetNames adds the ~ at the start for us + + err := client.SetNames(ident, msg.Params[3]) if err == errInvalidUsername { rb.Add(nil, server.name, ERR_INVALIDUSERNAME, client.t("Malformed username")) } diff --git a/oragono.yaml b/oragono.yaml index 263d1947..e217f3e2 100644 --- a/oragono.yaml +++ b/oragono.yaml @@ -415,6 +415,9 @@ limits: # nicklen is the max nick length allowed nicklen: 32 + # identlen is the max ident length allowed + identlen: 10 + # channellen is the max channel length allowed channellen: 64