mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-10 22:19:31 +01:00
Add 'k' snomask for kills (including those coming from dlines and klines)
This commit is contained in:
parent
3ee26041ff
commit
309ec8191e
@ -47,6 +47,7 @@ type Client struct {
|
|||||||
class *OperClass
|
class *OperClass
|
||||||
ctime time.Time
|
ctime time.Time
|
||||||
destroyMutex sync.Mutex
|
destroyMutex sync.Mutex
|
||||||
|
exitedSnomaskSent bool
|
||||||
flags map[Mode]bool
|
flags map[Mode]bool
|
||||||
hasQuit bool
|
hasQuit bool
|
||||||
hops int
|
hops int
|
||||||
@ -530,7 +531,9 @@ func (client *Client) destroy() {
|
|||||||
//TODO(dan): store quit message in user, if exists use that instead here
|
//TODO(dan): store quit message in user, if exists use that instead here
|
||||||
friend.Send(nil, client.nickMaskString, "QUIT", "Exited")
|
friend.Send(nil, client.nickMaskString, "QUIT", "Exited")
|
||||||
}
|
}
|
||||||
client.server.snomasks.Send(sno.LocalQuits, fmt.Sprintf(ircfmt.Unescape("%s$r quit"), client.nick))
|
if !client.exitedSnomaskSent {
|
||||||
|
client.server.snomasks.Send(sno.LocalQuits, fmt.Sprintf(ircfmt.Unescape("%s$r exited the network"), client.nick))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SendSplitMsgFromClient sends an IRC PRIVMSG/NOTICE coming from a specific client.
|
// SendSplitMsgFromClient sends an IRC PRIVMSG/NOTICE coming from a specific client.
|
||||||
|
10
irc/dline.go
10
irc/dline.go
@ -7,14 +7,17 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
|
"sort"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
|
"github.com/DanielOaks/girc-go/ircfmt"
|
||||||
"github.com/DanielOaks/girc-go/ircmsg"
|
"github.com/DanielOaks/girc-go/ircmsg"
|
||||||
"github.com/DanielOaks/oragono/irc/custime"
|
"github.com/DanielOaks/oragono/irc/custime"
|
||||||
|
"github.com/DanielOaks/oragono/irc/sno"
|
||||||
"github.com/tidwall/buntdb"
|
"github.com/tidwall/buntdb"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -325,6 +328,7 @@ func dlineHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
|||||||
var killClient bool
|
var killClient bool
|
||||||
if andKill {
|
if andKill {
|
||||||
var clientsToKill []*Client
|
var clientsToKill []*Client
|
||||||
|
var killedClientNicks []string
|
||||||
var toKill bool
|
var toKill bool
|
||||||
|
|
||||||
server.clients.ByNickMutex.RLock()
|
server.clients.ByNickMutex.RLock()
|
||||||
@ -337,11 +341,13 @@ func dlineHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
|||||||
|
|
||||||
if toKill {
|
if toKill {
|
||||||
clientsToKill = append(clientsToKill, mcl)
|
clientsToKill = append(clientsToKill, mcl)
|
||||||
|
killedClientNicks = append(killedClientNicks, mcl.nick)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
server.clients.ByNickMutex.RUnlock()
|
server.clients.ByNickMutex.RUnlock()
|
||||||
|
|
||||||
for _, mcl := range clientsToKill {
|
for _, mcl := range clientsToKill {
|
||||||
|
mcl.exitedSnomaskSent = true
|
||||||
mcl.Quit(fmt.Sprintf("You have been banned from this server (%s)", reason))
|
mcl.Quit(fmt.Sprintf("You have been banned from this server (%s)", reason))
|
||||||
if mcl == client {
|
if mcl == client {
|
||||||
killClient = true
|
killClient = true
|
||||||
@ -350,6 +356,10 @@ func dlineHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
|||||||
mcl.destroy()
|
mcl.destroy()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// send snomask
|
||||||
|
sort.Strings(killedClientNicks)
|
||||||
|
server.snomasks.Send(sno.LocalKills, fmt.Sprintf(ircfmt.Unescape("%s killed %d clients with a DLINE $c[grey][$r%s$c[grey]]"), client.nick, len(killedClientNicks), strings.Join(killedClientNicks, ", ")))
|
||||||
}
|
}
|
||||||
|
|
||||||
return killClient
|
return killClient
|
||||||
|
10
irc/kline.go
10
irc/kline.go
@ -6,12 +6,15 @@ package irc
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/DanielOaks/girc-go/ircfmt"
|
||||||
"github.com/DanielOaks/girc-go/ircmatch"
|
"github.com/DanielOaks/girc-go/ircmatch"
|
||||||
"github.com/DanielOaks/girc-go/ircmsg"
|
"github.com/DanielOaks/girc-go/ircmsg"
|
||||||
"github.com/DanielOaks/oragono/irc/custime"
|
"github.com/DanielOaks/oragono/irc/custime"
|
||||||
|
"github.com/DanielOaks/oragono/irc/sno"
|
||||||
"github.com/tidwall/buntdb"
|
"github.com/tidwall/buntdb"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -236,18 +239,21 @@ func klineHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
|||||||
var killClient bool
|
var killClient bool
|
||||||
if andKill {
|
if andKill {
|
||||||
var clientsToKill []*Client
|
var clientsToKill []*Client
|
||||||
|
var killedClientNicks []string
|
||||||
|
|
||||||
server.clients.ByNickMutex.RLock()
|
server.clients.ByNickMutex.RLock()
|
||||||
for _, mcl := range server.clients.ByNick {
|
for _, mcl := range server.clients.ByNick {
|
||||||
for _, clientMask := range mcl.AllNickmasks() {
|
for _, clientMask := range mcl.AllNickmasks() {
|
||||||
if matcher.Match(clientMask) {
|
if matcher.Match(clientMask) {
|
||||||
clientsToKill = append(clientsToKill, mcl)
|
clientsToKill = append(clientsToKill, mcl)
|
||||||
|
killedClientNicks = append(killedClientNicks, mcl.nick)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
server.clients.ByNickMutex.RUnlock()
|
server.clients.ByNickMutex.RUnlock()
|
||||||
|
|
||||||
for _, mcl := range clientsToKill {
|
for _, mcl := range clientsToKill {
|
||||||
|
mcl.exitedSnomaskSent = true
|
||||||
mcl.Quit(fmt.Sprintf("You have been banned from this server (%s)", reason))
|
mcl.Quit(fmt.Sprintf("You have been banned from this server (%s)", reason))
|
||||||
if mcl == client {
|
if mcl == client {
|
||||||
killClient = true
|
killClient = true
|
||||||
@ -256,6 +262,10 @@ func klineHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
|||||||
mcl.destroy()
|
mcl.destroy()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// send snomask
|
||||||
|
sort.Strings(killedClientNicks)
|
||||||
|
server.snomasks.Send(sno.LocalKills, fmt.Sprintf(ircfmt.Unescape("%s killed %d clients with a KLINE $c[grey][$r%s$c[grey]]"), client.nick, len(killedClientNicks), strings.Join(killedClientNicks, ", ")))
|
||||||
}
|
}
|
||||||
|
|
||||||
return killClient
|
return killClient
|
||||||
|
@ -2121,6 +2121,10 @@ func killHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
quitMsg := fmt.Sprintf("Killed (%s (%s))", client.nick, comment)
|
quitMsg := fmt.Sprintf("Killed (%s (%s))", client.nick, comment)
|
||||||
|
|
||||||
|
server.snomasks.Send(sno.LocalKills, fmt.Sprintf(ircfmt.Unescape("%s$r was killed by %s $c[grey][$r%s$c[grey]]"), target.nick, client.nick, comment))
|
||||||
|
target.exitedSnomaskSent = true
|
||||||
|
|
||||||
target.Quit(quitMsg)
|
target.Quit(quitMsg)
|
||||||
target.destroy()
|
target.destroy()
|
||||||
return false
|
return false
|
||||||
|
Loading…
Reference in New Issue
Block a user