3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-22 03:49:27 +01:00

Merge pull request #1950 from slingamn/kline_snotice.3

fix #1941
This commit is contained in:
Shivaram Lingamneni 2022-05-03 22:54:54 -04:00 committed by GitHub
commit f7853b15ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 2 deletions

View File

@ -80,6 +80,7 @@ type Client struct {
hostname string
invitedTo map[string]channelInvite
isSTSOnly bool
isKlined bool // #1941: k-line kills are special-cased to suppress some triggered notices/events
languages []string
lastActive time.Time // last time they sent a command that wasn't PONG or similar
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) {
details := client.detailsNoMutex()
sessionRemoved := false
registered := client.registered
isKlined := client.isKlined
// XXX a temporary (reattaching) client can be marked alwaysOn when it logs in,
// but then the session attaches to another client and we need to clean it up here
alwaysOn := registered && client.alwaysOn
@ -1341,10 +1343,12 @@ func (client *Client) destroy(session *Session) {
}
if registered {
if !isKlined {
client.server.snomasks.Send(sno.LocalQuits, fmt.Sprintf(ircfmt.Unescape("%s$r exited the network"), details.nick))
client.server.logger.Info("quit", fmt.Sprintf("%s is no longer on the server", details.nick))
}
}
}
// SendSplitMsgFromClient sends an IRC PRIVMSG/NOTICE coming from a specific client.
// Adds account-tag to the line as well.

View File

@ -550,6 +550,12 @@ func (client *Client) shouldFlushTimestamps() (result bool) {
return
}
func (client *Client) setKlined() {
client.stateMutex.Lock()
client.isKlined = true
client.stateMutex.Unlock()
}
func (channel *Channel) Name() string {
channel.stateMutex.RLock()
defer channel.stateMutex.RUnlock()

View File

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