mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-10 22:19:31 +01:00
modes: Limit length of beI mode lists
This commit is contained in:
parent
20cb3407cb
commit
78028135eb
@ -12,6 +12,7 @@ New release of Oragono!
|
|||||||
### Added
|
### Added
|
||||||
* Added operator classes, allowing for more finely-grained permissions for operators.
|
* Added operator classes, allowing for more finely-grained permissions for operators.
|
||||||
* Added automatic client connection limiting, similar to other IRCds.
|
* Added automatic client connection limiting, similar to other IRCds.
|
||||||
|
* Length of channel mode lists (ban / ban-except / invite-except) is now restricted to the limit in config.
|
||||||
* Added support for IRCv3 capability [`chghost`](http://ircv3.net/specs/extensions/chghost-3.2.html).
|
* Added support for IRCv3 capability [`chghost`](http://ircv3.net/specs/extensions/chghost-3.2.html).
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
@ -136,6 +136,7 @@ type Config struct {
|
|||||||
TopicLen uint `yaml:"topiclen"`
|
TopicLen uint `yaml:"topiclen"`
|
||||||
WhowasEntries uint `yaml:"whowas-entries"`
|
WhowasEntries uint `yaml:"whowas-entries"`
|
||||||
MonitorEntries uint `yaml:"monitor-entries"`
|
MonitorEntries uint `yaml:"monitor-entries"`
|
||||||
|
ChanListModes uint `yaml:"chan-list-modes"`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
11
irc/modes.go
11
irc/modes.go
@ -404,6 +404,9 @@ func cmodeHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
|||||||
changes = append(changes, &change)
|
changes = append(changes, &change)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// so we only output one warning for each list type when full
|
||||||
|
listFullWarned := make(map[ChannelMode]bool)
|
||||||
|
|
||||||
for _, change := range changes {
|
for _, change := range changes {
|
||||||
switch change.mode {
|
switch change.mode {
|
||||||
case BanMask, ExceptMask, InviteMask:
|
case BanMask, ExceptMask, InviteMask:
|
||||||
@ -428,6 +431,14 @@ func cmodeHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
|||||||
|
|
||||||
switch change.op {
|
switch change.op {
|
||||||
case Add:
|
case Add:
|
||||||
|
if len(list.masks) >= server.limits.ChanListModes {
|
||||||
|
if !listFullWarned[change.mode] {
|
||||||
|
client.Send(nil, server.name, ERR_BANLISTFULL, client.nick, channel.name, change.mode.String(), "Channel list is full")
|
||||||
|
listFullWarned[change.mode] = true
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
list.Add(mask)
|
list.Add(mask)
|
||||||
applied = append(applied, change)
|
applied = append(applied, change)
|
||||||
|
|
||||||
|
@ -39,6 +39,7 @@ type Limits struct {
|
|||||||
MonitorEntries int
|
MonitorEntries int
|
||||||
NickLen int
|
NickLen int
|
||||||
TopicLen int
|
TopicLen int
|
||||||
|
ChanListModes int
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListenerInterface represents an interface for a listener.
|
// ListenerInterface represents an interface for a listener.
|
||||||
@ -166,6 +167,7 @@ func NewServer(configFilename string, config *Config) *Server {
|
|||||||
MonitorEntries: int(config.Limits.MonitorEntries),
|
MonitorEntries: int(config.Limits.MonitorEntries),
|
||||||
NickLen: int(config.Limits.NickLen),
|
NickLen: int(config.Limits.NickLen),
|
||||||
TopicLen: int(config.Limits.TopicLen),
|
TopicLen: int(config.Limits.TopicLen),
|
||||||
|
ChanListModes: int(config.Limits.ChanListModes),
|
||||||
},
|
},
|
||||||
listeners: make(map[string]ListenerInterface),
|
listeners: make(map[string]ListenerInterface),
|
||||||
monitoring: make(map[string][]Client),
|
monitoring: make(map[string][]Client),
|
||||||
@ -266,7 +268,7 @@ func (server *Server) setISupport() {
|
|||||||
server.isupport.Add("EXCEPTS", "")
|
server.isupport.Add("EXCEPTS", "")
|
||||||
server.isupport.Add("INVEX", "")
|
server.isupport.Add("INVEX", "")
|
||||||
server.isupport.Add("KICKLEN", strconv.Itoa(server.limits.KickLen))
|
server.isupport.Add("KICKLEN", strconv.Itoa(server.limits.KickLen))
|
||||||
// server.isupport.Add("MAXLIST", "") //TODO(dan): Support max list length?
|
server.isupport.Add("MAXLIST", fmt.Sprintf("beI:%s", strconv.Itoa(server.limits.ChanListModes)))
|
||||||
// server.isupport.Add("MODES", "") //TODO(dan): Support max modes?
|
// server.isupport.Add("MODES", "") //TODO(dan): Support max modes?
|
||||||
server.isupport.Add("MONITOR", strconv.Itoa(server.limits.MonitorEntries))
|
server.isupport.Add("MONITOR", strconv.Itoa(server.limits.MonitorEntries))
|
||||||
server.isupport.Add("NETWORK", server.networkName)
|
server.isupport.Add("NETWORK", server.networkName)
|
||||||
@ -1056,6 +1058,7 @@ func (server *Server) rehash() error {
|
|||||||
MonitorEntries: int(config.Limits.MonitorEntries),
|
MonitorEntries: int(config.Limits.MonitorEntries),
|
||||||
NickLen: int(config.Limits.NickLen),
|
NickLen: int(config.Limits.NickLen),
|
||||||
TopicLen: int(config.Limits.TopicLen),
|
TopicLen: int(config.Limits.TopicLen),
|
||||||
|
ChanListModes: int(config.Limits.ChanListModes),
|
||||||
}
|
}
|
||||||
server.operclasses = *operclasses
|
server.operclasses = *operclasses
|
||||||
server.operators = opers
|
server.operators = opers
|
||||||
|
@ -160,3 +160,6 @@ limits:
|
|||||||
|
|
||||||
# whowas entries to store
|
# whowas entries to store
|
||||||
whowas-entries: 100
|
whowas-entries: 100
|
||||||
|
|
||||||
|
# maximum length of channel lists (beI modes)
|
||||||
|
chan-list-modes: 60
|
||||||
|
Loading…
Reference in New Issue
Block a user