Преглед на файлове

modes: Limit length of beI mode lists

tags/v0.4.0
Daniel Oaks преди 7 години
родител
ревизия
78028135eb
променени са 5 файла, в които са добавени 20 реда и са изтрити 1 реда
  1. 1
    0
      CHANGELOG.md
  2. 1
    0
      irc/config.go
  3. 11
    0
      irc/modes.go
  4. 4
    1
      irc/server.go
  5. 3
    0
      oragono.yaml

+ 1
- 0
CHANGELOG.md Целия файл

@@ -12,6 +12,7 @@ New release of Oragono!
12 12
 ### Added
13 13
 * Added operator classes, allowing for more finely-grained permissions for operators.
14 14
 * Added automatic client connection limiting, similar to other IRCds.
15
+* Length of channel mode lists (ban / ban-except / invite-except) is now restricted to the limit in config.
15 16
 * Added support for IRCv3 capability [`chghost`](http://ircv3.net/specs/extensions/chghost-3.2.html).
16 17
 
17 18
 ### Changed

+ 1
- 0
irc/config.go Целия файл

@@ -136,6 +136,7 @@ type Config struct {
136 136
 		TopicLen       uint `yaml:"topiclen"`
137 137
 		WhowasEntries  uint `yaml:"whowas-entries"`
138 138
 		MonitorEntries uint `yaml:"monitor-entries"`
139
+		ChanListModes  uint `yaml:"chan-list-modes"`
139 140
 	}
140 141
 }
141 142
 

+ 11
- 0
irc/modes.go Целия файл

@@ -404,6 +404,9 @@ func cmodeHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
404 404
 			changes = append(changes, &change)
405 405
 		}
406 406
 
407
+		// so we only output one warning for each list type when full
408
+		listFullWarned := make(map[ChannelMode]bool)
409
+
407 410
 		for _, change := range changes {
408 411
 			switch change.mode {
409 412
 			case BanMask, ExceptMask, InviteMask:
@@ -428,6 +431,14 @@ func cmodeHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
428 431
 
429 432
 				switch change.op {
430 433
 				case Add:
434
+					if len(list.masks) >= server.limits.ChanListModes {
435
+						if !listFullWarned[change.mode] {
436
+							client.Send(nil, server.name, ERR_BANLISTFULL, client.nick, channel.name, change.mode.String(), "Channel list is full")
437
+							listFullWarned[change.mode] = true
438
+						}
439
+						continue
440
+					}
441
+
431 442
 					list.Add(mask)
432 443
 					applied = append(applied, change)
433 444
 

+ 4
- 1
irc/server.go Целия файл

@@ -39,6 +39,7 @@ type Limits struct {
39 39
 	MonitorEntries int
40 40
 	NickLen        int
41 41
 	TopicLen       int
42
+	ChanListModes  int
42 43
 }
43 44
 
44 45
 // ListenerInterface represents an interface for a listener.
@@ -166,6 +167,7 @@ func NewServer(configFilename string, config *Config) *Server {
166 167
 			MonitorEntries: int(config.Limits.MonitorEntries),
167 168
 			NickLen:        int(config.Limits.NickLen),
168 169
 			TopicLen:       int(config.Limits.TopicLen),
170
+			ChanListModes:  int(config.Limits.ChanListModes),
169 171
 		},
170 172
 		listeners:      make(map[string]ListenerInterface),
171 173
 		monitoring:     make(map[string][]Client),
@@ -266,7 +268,7 @@ func (server *Server) setISupport() {
266 268
 	server.isupport.Add("EXCEPTS", "")
267 269
 	server.isupport.Add("INVEX", "")
268 270
 	server.isupport.Add("KICKLEN", strconv.Itoa(server.limits.KickLen))
269
-	// server.isupport.Add("MAXLIST", "") //TODO(dan): Support max list length?
271
+	server.isupport.Add("MAXLIST", fmt.Sprintf("beI:%s", strconv.Itoa(server.limits.ChanListModes)))
270 272
 	// server.isupport.Add("MODES", "")   //TODO(dan): Support max modes?
271 273
 	server.isupport.Add("MONITOR", strconv.Itoa(server.limits.MonitorEntries))
272 274
 	server.isupport.Add("NETWORK", server.networkName)
@@ -1056,6 +1058,7 @@ func (server *Server) rehash() error {
1056 1058
 		MonitorEntries: int(config.Limits.MonitorEntries),
1057 1059
 		NickLen:        int(config.Limits.NickLen),
1058 1060
 		TopicLen:       int(config.Limits.TopicLen),
1061
+		ChanListModes:  int(config.Limits.ChanListModes),
1059 1062
 	}
1060 1063
 	server.operclasses = *operclasses
1061 1064
 	server.operators = opers

+ 3
- 0
oragono.yaml Целия файл

@@ -160,3 +160,6 @@ limits:
160 160
 
161 161
     # whowas entries to store
162 162
     whowas-entries: 100
163
+
164
+    # maximum length of channel lists (beI modes)
165
+    chan-list-modes: 60

Loading…
Отказ
Запис