mirror of
https://github.com/ergochat/ergo.git
synced 2025-02-18 06:30:39 +01:00
parent
0af0a0b445
commit
4e13f72ca9
@ -111,6 +111,8 @@ type Session struct {
|
|||||||
capState caps.State
|
capState caps.State
|
||||||
capVersion caps.Version
|
capVersion caps.Version
|
||||||
|
|
||||||
|
registrationMessages int
|
||||||
|
|
||||||
resumeID string
|
resumeID string
|
||||||
resumeDetails *ResumeDetails
|
resumeDetails *ResumeDetails
|
||||||
zncPlaybackTimes *zncPlaybackTimes
|
zncPlaybackTimes *zncPlaybackTimes
|
||||||
@ -396,6 +398,15 @@ func (client *Client) run(session *Session) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DoS hardening, #505
|
||||||
|
if !client.registered {
|
||||||
|
session.registrationMessages++
|
||||||
|
if client.server.Config().Limits.RegistrationMessages < session.registrationMessages {
|
||||||
|
client.Send(nil, client.server.name, ERR_UNKNOWNERROR, "*", client.t("You have sent too many registration messages"))
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
msg, err := ircmsg.ParseLineStrict(line, true, maxlenRest)
|
msg, err := ircmsg.ParseLineStrict(line, true, maxlenRest)
|
||||||
if err == ircmsg.ErrorLineIsEmpty {
|
if err == ircmsg.ErrorLineIsEmpty {
|
||||||
continue
|
continue
|
||||||
|
@ -214,16 +214,17 @@ type LineLenLimits struct {
|
|||||||
|
|
||||||
// Various server-enforced limits on data size.
|
// Various server-enforced limits on data size.
|
||||||
type Limits struct {
|
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"`
|
IdentLen int `yaml:"identlen"`
|
||||||
KickLen int `yaml:"kicklen"`
|
KickLen int `yaml:"kicklen"`
|
||||||
LineLen LineLenLimits `yaml:"linelen"`
|
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"`
|
||||||
|
RegistrationMessages int `yaml:"registration-messages"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// STSConfig controls the STS configuration/
|
// STSConfig controls the STS configuration/
|
||||||
@ -532,6 +533,9 @@ func LoadConfig(filename string) (config *Config, err error) {
|
|||||||
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
|
||||||
}
|
}
|
||||||
|
if config.Limits.RegistrationMessages == 0 {
|
||||||
|
config.Limits.RegistrationMessages = 1024
|
||||||
|
}
|
||||||
if config.Server.STS.Enabled {
|
if config.Server.STS.Enabled {
|
||||||
config.Server.STS.Duration, err = custime.ParseDuration(config.Server.STS.DurationString)
|
config.Server.STS.Duration, err = custime.ParseDuration(config.Server.STS.DurationString)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -557,6 +557,10 @@ limits:
|
|||||||
# configurable length for the rest of the message:
|
# configurable length for the rest of the message:
|
||||||
rest: 2048
|
rest: 2048
|
||||||
|
|
||||||
|
# maximum number of messages to accept during registration (prevents
|
||||||
|
# DoS / resource exhaustion attacks):
|
||||||
|
registration-messages: 1024
|
||||||
|
|
||||||
# fakelag: prevents clients from spamming commands too rapidly
|
# fakelag: prevents clients from spamming commands too rapidly
|
||||||
fakelag:
|
fakelag:
|
||||||
# whether to enforce fakelag
|
# whether to enforce fakelag
|
||||||
|
Loading…
x
Reference in New Issue
Block a user