Skip to content

Commit 188d8c4

Browse files
authored
Merge pull request #1728 from mogad0n/session_disconnect_sno
DISCONNECT Sno for always-on and/or multiclient
2 parents 77bfdd8 + 99cb1fd commit 188d8c4

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

default.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ opers:
654654
# modes are modes to auto-set upon opering-up. uncomment this to automatically
655655
# enable snomasks ("server notification masks" that alert you to server events;
656656
# see `/quote help snomasks` while opered-up for more information):
657-
#modes: +is acjknoqtuxv
657+
#modes: +is acdjknoqtuxv
658658

659659
# operators can be authenticated either by password (with the /OPER command),
660660
# or by certificate fingerprint, or both. if a password hash is set, then a

irc/client.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,6 +1310,9 @@ func (client *Client) destroy(session *Session) {
13101310
client.server.connectionLimiter.RemoveClient(flatip.FromNetIP(ip))
13111311
source = ip.String()
13121312
}
1313+
if !shouldDestroy {
1314+
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))
1315+
}
13131316
client.server.logger.Info("connect-ip", fmt.Sprintf("disconnecting session of %s from %s", details.nick, source))
13141317
}
13151318

irc/sno/constants.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ type Masks []Mask
1313
const (
1414
LocalAnnouncements Mask = 'a'
1515
LocalConnects Mask = 'c'
16+
LocalDisconnects Mask = 'd'
1617
LocalChannels Mask = 'j'
1718
LocalKills Mask = 'k'
1819
LocalNicks Mask = 'n'
@@ -29,6 +30,7 @@ var (
2930
NoticeMaskNames = map[Mask]string{
3031
LocalAnnouncements: "ANNOUNCEMENT",
3132
LocalConnects: "CONNECT",
33+
LocalDisconnects: "DISCONNECT",
3234
LocalChannels: "CHANNEL",
3335
LocalKills: "KILL",
3436
LocalNicks: "NICK",
@@ -44,6 +46,7 @@ var (
4446
ValidMasks = []Mask{
4547
LocalAnnouncements,
4648
LocalConnects,
49+
LocalDisconnects,
4750
LocalChannels,
4851
LocalKills,
4952
LocalNicks,

irc/sno/utils_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ func assertEqual(supplied, expected interface{}, t *testing.T) {
1717

1818
func TestEvaluateSnomaskChanges(t *testing.T) {
1919
add, remove, newArg := EvaluateSnomaskChanges(true, "*", nil)
20-
assertEqual(add, Masks{'a', 'c', 'j', 'k', 'n', 'o', 'q', 't', 'u', 'v', 'x'}, t)
20+
assertEqual(add, Masks{'a', 'c', 'd', 'j', 'k', 'n', 'o', 'q', 't', 'u', 'v', 'x'}, t)
2121
assertEqual(len(remove), 0, t)
22-
assertEqual(newArg, "+acjknoqtuvx", t)
22+
assertEqual(newArg, "+acdjknoqtuvx", t)
2323

2424
add, remove, newArg = EvaluateSnomaskChanges(true, "*", Masks{'a', 'u'})
25-
assertEqual(add, Masks{'c', 'j', 'k', 'n', 'o', 'q', 't', 'v', 'x'}, t)
25+
assertEqual(add, Masks{'c', 'd', 'j', 'k', 'n', 'o', 'q', 't', 'v', 'x'}, t)
2626
assertEqual(len(remove), 0, t)
27-
assertEqual(newArg, "+cjknoqtvx", t)
27+
assertEqual(newArg, "+cdjknoqtvx", t)
2828

2929
add, remove, newArg = EvaluateSnomaskChanges(true, "-a", Masks{'a', 'u'})
3030
assertEqual(len(add), 0, t)

traditional.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ opers:
627627
# modes are modes to auto-set upon opering-up. uncomment this to automatically
628628
# enable snomasks ("server notification masks" that alert you to server events;
629629
# see `/quote help snomasks` while opered-up for more information):
630-
#modes: +is acjknoqtuxv
630+
#modes: +is acdjknoqtuxv
631631

632632
# operators can be authenticated either by password (with the /OPER command),
633633
# or by certificate fingerprint, or both. if a password hash is set, then a

0 commit comments

Comments
 (0)