|
@@ -182,29 +182,31 @@ func NewServer(config *Config, logger *logger.Manager) (*Server, error) {
|
182
|
182
|
func (server *Server) setISupport() {
|
183
|
183
|
maxTargetsString := strconv.Itoa(maxTargets)
|
184
|
184
|
|
|
185
|
+ server.configurableStateMutex.RLock()
|
|
186
|
+
|
185
|
187
|
// add RPL_ISUPPORT tokens
|
186
|
|
- server.isupport = NewISupportList()
|
187
|
|
- server.isupport.Add("AWAYLEN", strconv.Itoa(server.limits.AwayLen))
|
188
|
|
- server.isupport.Add("CASEMAPPING", casemappingName)
|
189
|
|
- server.isupport.Add("CHANMODES", strings.Join([]string{Modes{BanMask, ExceptMask, InviteMask}.String(), "", Modes{UserLimit, Key}.String(), Modes{InviteOnly, Moderated, NoOutside, OpOnlyTopic, ChanRoleplaying, Secret}.String()}, ","))
|
190
|
|
- server.isupport.Add("CHANNELLEN", strconv.Itoa(server.limits.ChannelLen))
|
191
|
|
- server.isupport.Add("CHANTYPES", "#")
|
192
|
|
- server.isupport.Add("ELIST", "U")
|
193
|
|
- server.isupport.Add("EXCEPTS", "")
|
194
|
|
- server.isupport.Add("INVEX", "")
|
195
|
|
- server.isupport.Add("KICKLEN", strconv.Itoa(server.limits.KickLen))
|
196
|
|
- server.isupport.Add("MAXLIST", fmt.Sprintf("beI:%s", strconv.Itoa(server.limits.ChanListModes)))
|
197
|
|
- server.isupport.Add("MAXTARGETS", maxTargetsString)
|
198
|
|
- server.isupport.Add("MODES", "")
|
199
|
|
- server.isupport.Add("MONITOR", strconv.Itoa(server.limits.MonitorEntries))
|
200
|
|
- server.isupport.Add("NETWORK", server.networkName)
|
201
|
|
- server.isupport.Add("NICKLEN", strconv.Itoa(server.limits.NickLen))
|
202
|
|
- server.isupport.Add("PREFIX", "(qaohv)~&@%+")
|
203
|
|
- server.isupport.Add("RPCHAN", "E")
|
204
|
|
- server.isupport.Add("RPUSER", "E")
|
205
|
|
- server.isupport.Add("STATUSMSG", "~&@%+")
|
206
|
|
- server.isupport.Add("TARGMAX", fmt.Sprintf("NAMES:1,LIST:1,KICK:1,WHOIS:1,USERHOST:10,PRIVMSG:%s,TAGMSG:%s,NOTICE:%s,MONITOR:", maxTargetsString, maxTargetsString, maxTargetsString))
|
207
|
|
- server.isupport.Add("TOPICLEN", strconv.Itoa(server.limits.TopicLen))
|
|
188
|
+ isupport := NewISupportList()
|
|
189
|
+ isupport.Add("AWAYLEN", strconv.Itoa(server.limits.AwayLen))
|
|
190
|
+ isupport.Add("CASEMAPPING", casemappingName)
|
|
191
|
+ isupport.Add("CHANMODES", strings.Join([]string{Modes{BanMask, ExceptMask, InviteMask}.String(), "", Modes{UserLimit, Key}.String(), Modes{InviteOnly, Moderated, NoOutside, OpOnlyTopic, ChanRoleplaying, Secret}.String()}, ","))
|
|
192
|
+ isupport.Add("CHANNELLEN", strconv.Itoa(server.limits.ChannelLen))
|
|
193
|
+ isupport.Add("CHANTYPES", "#")
|
|
194
|
+ isupport.Add("ELIST", "U")
|
|
195
|
+ isupport.Add("EXCEPTS", "")
|
|
196
|
+ isupport.Add("INVEX", "")
|
|
197
|
+ isupport.Add("KICKLEN", strconv.Itoa(server.limits.KickLen))
|
|
198
|
+ isupport.Add("MAXLIST", fmt.Sprintf("beI:%s", strconv.Itoa(server.limits.ChanListModes)))
|
|
199
|
+ isupport.Add("MAXTARGETS", maxTargetsString)
|
|
200
|
+ isupport.Add("MODES", "")
|
|
201
|
+ isupport.Add("MONITOR", strconv.Itoa(server.limits.MonitorEntries))
|
|
202
|
+ isupport.Add("NETWORK", server.networkName)
|
|
203
|
+ isupport.Add("NICKLEN", strconv.Itoa(server.limits.NickLen))
|
|
204
|
+ isupport.Add("PREFIX", "(qaohv)~&@%+")
|
|
205
|
+ isupport.Add("RPCHAN", "E")
|
|
206
|
+ isupport.Add("RPUSER", "E")
|
|
207
|
+ isupport.Add("STATUSMSG", "~&@%+")
|
|
208
|
+ isupport.Add("TARGMAX", fmt.Sprintf("NAMES:1,LIST:1,KICK:1,WHOIS:1,USERHOST:10,PRIVMSG:%s,TAGMSG:%s,NOTICE:%s,MONITOR:", maxTargetsString, maxTargetsString, maxTargetsString))
|
|
209
|
+ isupport.Add("TOPICLEN", strconv.Itoa(server.limits.TopicLen))
|
208
|
210
|
|
209
|
211
|
// account registration
|
210
|
212
|
if server.accountRegistration.Enabled {
|
|
@@ -216,12 +218,18 @@ func (server *Server) setISupport() {
|
216
|
218
|
}
|
217
|
219
|
}
|
218
|
220
|
|
219
|
|
- server.isupport.Add("REGCOMMANDS", "CREATE,VERIFY")
|
220
|
|
- server.isupport.Add("REGCALLBACKS", strings.Join(enabledCallbacks, ","))
|
221
|
|
- server.isupport.Add("REGCREDTYPES", "passphrase,certfp")
|
|
221
|
+ isupport.Add("REGCOMMANDS", "CREATE,VERIFY")
|
|
222
|
+ isupport.Add("REGCALLBACKS", strings.Join(enabledCallbacks, ","))
|
|
223
|
+ isupport.Add("REGCREDTYPES", "passphrase,certfp")
|
222
|
224
|
}
|
223
|
225
|
|
224
|
|
- server.isupport.RegenerateCachedReply()
|
|
226
|
+ server.configurableStateMutex.RUnlock()
|
|
227
|
+
|
|
228
|
+ isupport.RegenerateCachedReply()
|
|
229
|
+
|
|
230
|
+ server.configurableStateMutex.Lock()
|
|
231
|
+ server.isupport = isupport
|
|
232
|
+ server.configurableStateMutex.Unlock()
|
225
|
233
|
}
|
226
|
234
|
|
227
|
235
|
func loadChannelList(channel *Channel, list string, maskMode Mode) {
|
|
@@ -440,15 +448,16 @@ func (server *Server) tryRegister(c *Client) {
|
440
|
448
|
// MOTD serves the Message of the Day.
|
441
|
449
|
func (server *Server) MOTD(client *Client) {
|
442
|
450
|
server.configurableStateMutex.RLock()
|
443
|
|
- defer server.configurableStateMutex.RUnlock()
|
|
451
|
+ motdLines := server.motdLines
|
|
452
|
+ server.configurableStateMutex.RUnlock()
|
444
|
453
|
|
445
|
|
- if len(server.motdLines) < 1 {
|
|
454
|
+ if len(motdLines) < 1 {
|
446
|
455
|
client.Send(nil, server.name, ERR_NOMOTD, client.nick, "MOTD File is missing")
|
447
|
456
|
return
|
448
|
457
|
}
|
449
|
458
|
|
450
|
459
|
client.Send(nil, server.name, RPL_MOTDSTART, client.nick, fmt.Sprintf("- %s Message of the day - ", server.name))
|
451
|
|
- for _, line := range server.motdLines {
|
|
460
|
+ for _, line := range motdLines {
|
452
|
461
|
client.Send(nil, server.name, RPL_MOTD, client.nick, line)
|
453
|
462
|
}
|
454
|
463
|
client.Send(nil, server.name, RPL_ENDOFMOTD, client.nick, "End of MOTD command")
|
|
@@ -691,7 +700,7 @@ func joinHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
691
|
700
|
|
692
|
701
|
channel := server.channels.Get(casefoldedName)
|
693
|
702
|
if channel == nil {
|
694
|
|
- if len(casefoldedName) > server.limits.ChannelLen {
|
|
703
|
+ if len(casefoldedName) > server.getLimits().ChannelLen {
|
695
|
704
|
client.Send(nil, server.name, ERR_NOSUCHCHANNEL, client.nick, name, "No such channel")
|
696
|
705
|
continue
|
697
|
706
|
}
|
|
@@ -1257,15 +1266,19 @@ func (server *Server) applyConfig(config *Config, initial bool) error {
|
1257
|
1266
|
|
1258
|
1267
|
// sanity checks complete, start modifying server state
|
1259
|
1268
|
|
1260
|
|
- server.name = config.Server.Name
|
1261
|
|
- server.nameCasefolded = casefoldedName
|
|
1269
|
+ if initial {
|
|
1270
|
+ server.name = config.Server.Name
|
|
1271
|
+ server.nameCasefolded = casefoldedName
|
|
1272
|
+ }
|
1262
|
1273
|
server.networkName = config.Network.Name
|
1263
|
1274
|
|
|
1275
|
+ server.configurableStateMutex.Lock()
|
1264
|
1276
|
if config.Server.Password != "" {
|
1265
|
1277
|
server.password = config.Server.PasswordBytes()
|
1266
|
1278
|
} else {
|
1267
|
1279
|
server.password = nil
|
1268
|
1280
|
}
|
|
1281
|
+ server.configurableStateMutex.Unlock()
|
1269
|
1282
|
|
1270
|
1283
|
// apply new PROXY command restrictions
|
1271
|
1284
|
server.proxyAllowedFrom = config.Server.ProxyAllowedFrom
|
|
@@ -1372,6 +1385,7 @@ func (server *Server) applyConfig(config *Config, initial bool) error {
|
1372
|
1385
|
}
|
1373
|
1386
|
|
1374
|
1387
|
// set server options
|
|
1388
|
+ server.configurableStateMutex.Lock()
|
1375
|
1389
|
lineLenConfig := LineLenLimits{
|
1376
|
1390
|
Tags: config.Limits.LineLen.Tags,
|
1377
|
1391
|
Rest: config.Limits.LineLen.Rest,
|
|
@@ -1395,13 +1409,14 @@ func (server *Server) applyConfig(config *Config, initial bool) error {
|
1395
|
1409
|
server.accountRegistration = &accountReg
|
1396
|
1410
|
server.channelRegistrationEnabled = config.Channels.Registration.Enabled
|
1397
|
1411
|
|
1398
|
|
- server.configurableStateMutex.Lock()
|
1399
|
1412
|
server.defaultChannelModes = ParseDefaultChannelModes(config)
|
1400
|
1413
|
server.configurableStateMutex.Unlock()
|
1401
|
1414
|
|
1402
|
1415
|
// set new sendqueue size
|
1403
|
1416
|
if config.Server.MaxSendQBytes != server.MaxSendQBytes {
|
|
1417
|
+ server.configurableStateMutex.Lock()
|
1404
|
1418
|
server.MaxSendQBytes = config.Server.MaxSendQBytes
|
|
1419
|
+ server.configurableStateMutex.Unlock()
|
1405
|
1420
|
|
1406
|
1421
|
// update on all clients
|
1407
|
1422
|
server.clients.ByNickMutex.RLock()
|
|
@@ -1469,8 +1484,8 @@ func (server *Server) loadMOTD(motdPath string) error {
|
1469
|
1484
|
}
|
1470
|
1485
|
|
1471
|
1486
|
server.configurableStateMutex.Lock()
|
1472
|
|
- defer server.configurableStateMutex.Unlock()
|
1473
|
1487
|
server.motdLines = motdLines
|
|
1488
|
+ server.configurableStateMutex.Unlock()
|
1474
|
1489
|
return nil
|
1475
|
1490
|
}
|
1476
|
1491
|
|
|
@@ -1628,8 +1643,9 @@ func awayHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
1628
|
1643
|
if len(msg.Params) > 0 {
|
1629
|
1644
|
isAway = true
|
1630
|
1645
|
text = msg.Params[0]
|
1631
|
|
- if len(text) > server.limits.AwayLen {
|
1632
|
|
- text = text[:server.limits.AwayLen]
|
|
1646
|
+ awayLen := server.getLimits().AwayLen
|
|
1647
|
+ if len(text) > awayLen {
|
|
1648
|
+ text = text[:awayLen]
|
1633
|
1649
|
}
|
1634
|
1650
|
}
|
1635
|
1651
|
|