3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-15 00:19:29 +01:00

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 # modes are modes to auto-set upon opering-up. uncomment this to automatically
# enable snomasks ("server notification masks" that alert you to server events; # enable snomasks ("server notification masks" that alert you to server events;
# see `/quote help snomasks` while opered-up for more information): # 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), # 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 # 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)) client.server.connectionLimiter.RemoveClient(flatip.FromNetIP(ip))
source = ip.String() 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)) 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 ( const (
LocalAnnouncements Mask = 'a' LocalAnnouncements Mask = 'a'
LocalConnects Mask = 'c' LocalConnects Mask = 'c'
LocalDisconnects Mask = 'd'
LocalChannels Mask = 'j' LocalChannels Mask = 'j'
LocalKills Mask = 'k' LocalKills Mask = 'k'
LocalNicks Mask = 'n' LocalNicks Mask = 'n'
@ -29,6 +30,7 @@ var (
NoticeMaskNames = map[Mask]string{ NoticeMaskNames = map[Mask]string{
LocalAnnouncements: "ANNOUNCEMENT", LocalAnnouncements: "ANNOUNCEMENT",
LocalConnects: "CONNECT", LocalConnects: "CONNECT",
LocalDisconnects: "DISCONNECT",
LocalChannels: "CHANNEL", LocalChannels: "CHANNEL",
LocalKills: "KILL", LocalKills: "KILL",
LocalNicks: "NICK", LocalNicks: "NICK",
@ -44,6 +46,7 @@ var (
ValidMasks = []Mask{ ValidMasks = []Mask{
LocalAnnouncements, LocalAnnouncements,
LocalConnects, LocalConnects,
LocalDisconnects,
LocalChannels, LocalChannels,
LocalKills, LocalKills,
LocalNicks, LocalNicks,

View File

@ -17,14 +17,14 @@ func assertEqual(supplied, expected interface{}, t *testing.T) {
func TestEvaluateSnomaskChanges(t *testing.T) { func TestEvaluateSnomaskChanges(t *testing.T) {
add, remove, newArg := EvaluateSnomaskChanges(true, "*", nil) 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(len(remove), 0, t)
assertEqual(newArg, "+acjknoqtuvx", t) assertEqual(newArg, "+acdjknoqtuvx", t)
add, remove, newArg = EvaluateSnomaskChanges(true, "*", Masks{'a', 'u'}) 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(len(remove), 0, t)
assertEqual(newArg, "+cjknoqtvx", t) assertEqual(newArg, "+cdjknoqtvx", t)
add, remove, newArg = EvaluateSnomaskChanges(true, "-a", Masks{'a', 'u'}) add, remove, newArg = EvaluateSnomaskChanges(true, "-a", Masks{'a', 'u'})
assertEqual(len(add), 0, t) 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 # modes are modes to auto-set upon opering-up. uncomment this to automatically
# enable snomasks ("server notification masks" that alert you to server events; # enable snomasks ("server notification masks" that alert you to server events;
# see `/quote help snomasks` while opered-up for more information): # 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), # 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 # or by certificate fingerprint, or both. if a password hash is set, then a