Преглед изворни кода

fix #1941

KLINE'd clients would produce a QUIT snotice without a corresponding
CONNECT snotice; explicitly suppress the QUIT snotice.
tags/v2.10.0-rc1
Shivaram Lingamneni пре 2 година
родитељ
комит
077081076c
3 измењених фајлова са 14 додато и 2 уклоњено
  1. 6
    2
      irc/client.go
  2. 6
    0
      irc/getters.go
  3. 2
    0
      irc/server.go

+ 6
- 2
irc/client.go Прегледај датотеку

@@ -80,6 +80,7 @@ type Client struct {
80 80
 	hostname           string
81 81
 	invitedTo          map[string]channelInvite
82 82
 	isSTSOnly          bool
83
+	isKlined           bool // #1941: k-line kills are special-cased to suppress some triggered notices/events
83 84
 	languages          []string
84 85
 	lastActive         time.Time            // last time they sent a command that wasn't PONG or similar
85 86
 	lastSeen           map[string]time.Time // maps device ID (including "") to time of last received command
@@ -1181,6 +1182,7 @@ func (client *Client) destroy(session *Session) {
1181 1182
 	details := client.detailsNoMutex()
1182 1183
 	sessionRemoved := false
1183 1184
 	registered := client.registered
1185
+	isKlined := client.isKlined
1184 1186
 	// XXX a temporary (reattaching) client can be marked alwaysOn when it logs in,
1185 1187
 	// but then the session attaches to another client and we need to clean it up here
1186 1188
 	alwaysOn := registered && client.alwaysOn
@@ -1341,8 +1343,10 @@ func (client *Client) destroy(session *Session) {
1341 1343
 	}
1342 1344
 
1343 1345
 	if registered {
1344
-		client.server.snomasks.Send(sno.LocalQuits, fmt.Sprintf(ircfmt.Unescape("%s$r exited the network"), details.nick))
1345
-		client.server.logger.Info("quit", fmt.Sprintf("%s is no longer on the server", details.nick))
1346
+		if !isKlined {
1347
+			client.server.snomasks.Send(sno.LocalQuits, fmt.Sprintf(ircfmt.Unescape("%s$r exited the network"), details.nick))
1348
+			client.server.logger.Info("quit", fmt.Sprintf("%s is no longer on the server", details.nick))
1349
+		}
1346 1350
 	}
1347 1351
 }
1348 1352
 

+ 6
- 0
irc/getters.go Прегледај датотеку

@@ -550,6 +550,12 @@ func (client *Client) shouldFlushTimestamps() (result bool) {
550 550
 	return
551 551
 }
552 552
 
553
+func (client *Client) setKlined() {
554
+	client.stateMutex.Lock()
555
+	client.isKlined = true
556
+	client.stateMutex.Unlock()
557
+}
558
+
553 559
 func (channel *Channel) Name() string {
554 560
 	channel.stateMutex.RLock()
555 561
 	defer channel.stateMutex.RUnlock()

+ 2
- 0
irc/server.go Прегледај датотеку

@@ -373,7 +373,9 @@ func (server *Server) tryRegister(c *Client, session *Session) (exiting bool) {
373 373
 	if !session.IP().IsLoopback() || session.isTor {
374 374
 		isBanned, info := server.klines.CheckMasks(c.AllNickmasks()...)
375 375
 		if isBanned {
376
+			c.setKlined()
376 377
 			c.Quit(info.BanMessage(c.t("You are banned from this server (%s)")), nil)
378
+			server.logger.Info("connect", "Client rejected by k-line", c.NickMaskString())
377 379
 			return true
378 380
 		}
379 381
 	}

Loading…
Откажи
Сачувај