DISCONNECT Sno for always-on and/or multiclient

This commit is contained in:
Pratyush Desai 2021-07-03 04:41:42 +05:30
parent 62d78a64cb
commit 99cb1fd02c
5 changed files with 12 additions and 6 deletions

View File

@ -654,7 +654,7 @@ opers:
# modes are modes to auto-set upon opering-up. uncomment this to automatically
# enable snomasks ("server notification masks" that alert you to server events;
# see `/quote help snomasks` while opered-up for more information):
#modes: +is acjknoqtuxv
#modes: +is acdjknoqtuxv
# operators can be authenticated either by password (with the /OPER command),
# or by certificate fingerprint, or both. if a password hash is set, then a

View File

@ -1310,6 +1310,9 @@ func (client *Client) destroy(session *Session) {
client.server.connectionLimiter.RemoveClient(flatip.FromNetIP(ip))
source = ip.String()
}
if !shouldDestroy {
client.server.snomasks.Send(sno.LocalDisconnects, fmt.Sprintf(ircfmt.Unescape("Client session disconnected for [a:%s] [h:%s] [ip:%s]"), details.accountName, session.rawHostname, source))
}
client.server.logger.Info("connect-ip", fmt.Sprintf("disconnecting session of %s from %s", details.nick, source))
}

View File

@ -13,6 +13,7 @@ type Masks []Mask
const (
LocalAnnouncements Mask = 'a'
LocalConnects Mask = 'c'
LocalDisconnects Mask = 'd'
LocalChannels Mask = 'j'
LocalKills Mask = 'k'
LocalNicks Mask = 'n'
@ -29,6 +30,7 @@ var (
NoticeMaskNames = map[Mask]string{
LocalAnnouncements: "ANNOUNCEMENT",
LocalConnects: "CONNECT",
LocalDisconnects: "DISCONNECT",
LocalChannels: "CHANNEL",
LocalKills: "KILL",
LocalNicks: "NICK",
@ -44,6 +46,7 @@ var (
ValidMasks = []Mask{
LocalAnnouncements,
LocalConnects,
LocalDisconnects,
LocalChannels,
LocalKills,
LocalNicks,

View File

@ -17,14 +17,14 @@ func assertEqual(supplied, expected interface{}, t *testing.T) {
func TestEvaluateSnomaskChanges(t *testing.T) {
add, remove, newArg := EvaluateSnomaskChanges(true, "*", nil)
assertEqual(add, Masks{'a', 'c', 'j', 'k', 'n', 'o', 'q', 't', 'u', 'v', 'x'}, t)
assertEqual(add, Masks{'a', 'c', 'd', 'j', 'k', 'n', 'o', 'q', 't', 'u', 'v', 'x'}, t)
assertEqual(len(remove), 0, t)
assertEqual(newArg, "+acjknoqtuvx", t)
assertEqual(newArg, "+acdjknoqtuvx", t)
add, remove, newArg = EvaluateSnomaskChanges(true, "*", Masks{'a', 'u'})
assertEqual(add, Masks{'c', 'j', 'k', 'n', 'o', 'q', 't', 'v', 'x'}, t)
assertEqual(add, Masks{'c', 'd', 'j', 'k', 'n', 'o', 'q', 't', 'v', 'x'}, t)
assertEqual(len(remove), 0, t)
assertEqual(newArg, "+cjknoqtvx", t)
assertEqual(newArg, "+cdjknoqtvx", t)
add, remove, newArg = EvaluateSnomaskChanges(true, "-a", Masks{'a', 'u'})
assertEqual(len(add), 0, t)

View File

@ -627,7 +627,7 @@ opers:
# modes are modes to auto-set upon opering-up. uncomment this to automatically
# enable snomasks ("server notification masks" that alert you to server events;
# see `/quote help snomasks` while opered-up for more information):
#modes: +is acjknoqtuxv
#modes: +is acdjknoqtuxv
# operators can be authenticated either by password (with the /OPER command),
# or by certificate fingerprint, or both. if a password hash is set, then a