mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-25 13:29:27 +01:00
Restrict ident length similar to other servers
This commit is contained in:
parent
8cd5db1194
commit
cfbb4361dc
@ -176,12 +176,12 @@ func NewClient(server *Server, conn net.Conn, isTLS bool) {
|
|||||||
client.Notice(client.t("*** Looking up your username"))
|
client.Notice(client.t("*** Looking up your username"))
|
||||||
resp, err := ident.Query(clientHost, serverPort, clientPort, IdentTimeoutSeconds)
|
resp, err := ident.Query(clientHost, serverPort, clientPort, IdentTimeoutSeconds)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
username := resp.Identifier
|
ident := resp.Identifier[:config.Limits.IdentLen-1]
|
||||||
cfusername, err := CasefoldName(username)
|
if isIdent(ident) {
|
||||||
if err == nil {
|
identLower := strings.ToLower(ident) // idents can only be ASCII chars only
|
||||||
client.Notice(client.t("*** Found your username"))
|
client.Notice(client.t("*** Found your username"))
|
||||||
client.username = username
|
client.username = ident
|
||||||
client.usernameCasefolded = cfusername
|
client.usernameCasefolded = identLower
|
||||||
// we don't need to updateNickMask here since nickMask is not used for anything yet
|
// we don't need to updateNickMask here since nickMask is not used for anything yet
|
||||||
} else {
|
} else {
|
||||||
client.Notice(client.t("*** Got a malformed username, ignoring"))
|
client.Notice(client.t("*** Got a malformed username, ignoring"))
|
||||||
|
@ -206,12 +206,13 @@ type Limits struct {
|
|||||||
AwayLen int `yaml:"awaylen"`
|
AwayLen int `yaml:"awaylen"`
|
||||||
ChanListModes int `yaml:"chan-list-modes"`
|
ChanListModes int `yaml:"chan-list-modes"`
|
||||||
ChannelLen int `yaml:"channellen"`
|
ChannelLen int `yaml:"channellen"`
|
||||||
|
IdentLen int `yaml:"identlen"`
|
||||||
KickLen int `yaml:"kicklen"`
|
KickLen int `yaml:"kicklen"`
|
||||||
|
LineLen LineLenLimits `yaml:"linelen"`
|
||||||
MonitorEntries int `yaml:"monitor-entries"`
|
MonitorEntries int `yaml:"monitor-entries"`
|
||||||
NickLen int `yaml:"nicklen"`
|
NickLen int `yaml:"nicklen"`
|
||||||
TopicLen int `yaml:"topiclen"`
|
TopicLen int `yaml:"topiclen"`
|
||||||
WhowasEntries int `yaml:"whowas-entries"`
|
WhowasEntries int `yaml:"whowas-entries"`
|
||||||
LineLen LineLenLimits `yaml:"linelen"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// STSConfig controls the STS configuration/
|
// STSConfig controls the STS configuration/
|
||||||
@ -491,6 +492,10 @@ func LoadConfig(filename string) (config *Config, err error) {
|
|||||||
if len(config.Server.Listen) == 0 {
|
if len(config.Server.Listen) == 0 {
|
||||||
return nil, ErrNoListenersDefined
|
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 {
|
if config.Limits.NickLen < 1 || config.Limits.ChannelLen < 2 || config.Limits.AwayLen < 1 || config.Limits.KickLen < 1 || config.Limits.TopicLen < 1 {
|
||||||
return nil, ErrLimitsAreInsane
|
return nil, ErrLimitsAreInsane
|
||||||
}
|
}
|
||||||
|
@ -2193,7 +2193,9 @@ func userHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Resp
|
|||||||
return false
|
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 {
|
if err == errInvalidUsername {
|
||||||
rb.Add(nil, server.name, ERR_INVALIDUSERNAME, client.t("Malformed username"))
|
rb.Add(nil, server.name, ERR_INVALIDUSERNAME, client.t("Malformed username"))
|
||||||
}
|
}
|
||||||
|
@ -415,6 +415,9 @@ limits:
|
|||||||
# nicklen is the max nick length allowed
|
# nicklen is the max nick length allowed
|
||||||
nicklen: 32
|
nicklen: 32
|
||||||
|
|
||||||
|
# identlen is the max ident length allowed
|
||||||
|
identlen: 10
|
||||||
|
|
||||||
# channellen is the max channel length allowed
|
# channellen is the max channel length allowed
|
||||||
channellen: 64
|
channellen: 64
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user