1
0
Fork 0
forked from External/ergo

Merge pull request #341 from oragono/restrict-usernames

Restrict idents as other servers do
This commit is contained in:
Shivaram Lingamneni 2019-02-03 15:24:08 -05:00 committed by GitHub
commit 057d00b2c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 73 additions and 11 deletions

View file

@ -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 = 20
}
if config.Limits.NickLen < 1 || config.Limits.ChannelLen < 2 || config.Limits.AwayLen < 1 || config.Limits.KickLen < 1 || config.Limits.TopicLen < 1 {
return nil, ErrLimitsAreInsane
}