Browse Source

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 years ago
parent
commit
077081076c
3 changed files with 14 additions and 2 deletions
  1. 6
    2
      irc/client.go
  2. 6
    0
      irc/getters.go
  3. 2
    0
      irc/server.go

+ 6
- 2
irc/client.go View File

80
 	hostname           string
80
 	hostname           string
81
 	invitedTo          map[string]channelInvite
81
 	invitedTo          map[string]channelInvite
82
 	isSTSOnly          bool
82
 	isSTSOnly          bool
83
+	isKlined           bool // #1941: k-line kills are special-cased to suppress some triggered notices/events
83
 	languages          []string
84
 	languages          []string
84
 	lastActive         time.Time            // last time they sent a command that wasn't PONG or similar
85
 	lastActive         time.Time            // last time they sent a command that wasn't PONG or similar
85
 	lastSeen           map[string]time.Time // maps device ID (including "") to time of last received command
86
 	lastSeen           map[string]time.Time // maps device ID (including "") to time of last received command
1181
 	details := client.detailsNoMutex()
1182
 	details := client.detailsNoMutex()
1182
 	sessionRemoved := false
1183
 	sessionRemoved := false
1183
 	registered := client.registered
1184
 	registered := client.registered
1185
+	isKlined := client.isKlined
1184
 	// XXX a temporary (reattaching) client can be marked alwaysOn when it logs in,
1186
 	// XXX a temporary (reattaching) client can be marked alwaysOn when it logs in,
1185
 	// but then the session attaches to another client and we need to clean it up here
1187
 	// but then the session attaches to another client and we need to clean it up here
1186
 	alwaysOn := registered && client.alwaysOn
1188
 	alwaysOn := registered && client.alwaysOn
1341
 	}
1343
 	}
1342
 
1344
 
1343
 	if registered {
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 View File

550
 	return
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
 func (channel *Channel) Name() string {
559
 func (channel *Channel) Name() string {
554
 	channel.stateMutex.RLock()
560
 	channel.stateMutex.RLock()
555
 	defer channel.stateMutex.RUnlock()
561
 	defer channel.stateMutex.RUnlock()

+ 2
- 0
irc/server.go View File

373
 	if !session.IP().IsLoopback() || session.isTor {
373
 	if !session.IP().IsLoopback() || session.isTor {
374
 		isBanned, info := server.klines.CheckMasks(c.AllNickmasks()...)
374
 		isBanned, info := server.klines.CheckMasks(c.AllNickmasks()...)
375
 		if isBanned {
375
 		if isBanned {
376
+			c.setKlined()
376
 			c.Quit(info.BanMessage(c.t("You are banned from this server (%s)")), nil)
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
 			return true
379
 			return true
378
 		}
380
 		}
379
 	}
381
 	}

Loading…
Cancel
Save