mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-10 22:19:31 +01:00
Allow simple way of listing DLINEs and KLINEs
This commit is contained in:
parent
7217bf5b85
commit
1324c5ff83
16
irc/dline.go
16
irc/dline.go
@ -213,6 +213,7 @@ func (dm *DLineManager) CheckIP(addr net.IP) (isBanned bool, info *IPBanInfo) {
|
||||
}
|
||||
|
||||
// DLINE [ANDKILL] [MYSELF] [duration] <ip>/<net> [ON <server>] [reason [| oper reason]]
|
||||
// DLINE LIST
|
||||
func dlineHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
||||
// check oper permissions
|
||||
if !client.class.Capabilities["oper:local_ban"] {
|
||||
@ -222,6 +223,21 @@ func dlineHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
||||
|
||||
currentArg := 0
|
||||
|
||||
// if they say LIST, we just list the current dlines
|
||||
if len(msg.Params) == currentArg+1 && strings.ToLower(msg.Params[currentArg]) == "list" {
|
||||
bans := server.dlines.AllBans()
|
||||
|
||||
if len(bans) == 0 {
|
||||
client.Notice("No DLINEs have been set!")
|
||||
}
|
||||
|
||||
for key, info := range bans {
|
||||
client.Notice(fmt.Sprintf("Ban - %s - %s", key, info.BanMessage("%s")))
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// when setting a ban, if they say "ANDKILL" we should also kill all users who match it
|
||||
var andKill bool
|
||||
if len(msg.Params) > currentArg+1 && strings.ToLower(msg.Params[currentArg]) == "andkill" {
|
||||
|
10
irc/help.go
10
irc/help.go
@ -150,6 +150,7 @@ Prints debug information about the IRCd. <option> can be one of:
|
||||
"dline": {
|
||||
oper: true,
|
||||
text: `DLINE [ANDKILL] [MYSELF] [duration] <ip>/<net> [ON <server>] [reason [| oper reason]]
|
||||
DLINE LIST
|
||||
|
||||
Bans an IP address or network from connecting to the server. If the duration is
|
||||
given then only for that long. The reason is shown to the user themselves, but
|
||||
@ -172,7 +173,9 @@ from. If "MYSELF" is not given, trying to DLINE yourself will result in an error
|
||||
|
||||
ON <server> specifies that the ban is to be set on that specific server.
|
||||
|
||||
[reason] and [oper reason], if they exist, are separated by a vertical bar (|).`,
|
||||
[reason] and [oper reason], if they exist, are separated by a vertical bar (|).
|
||||
|
||||
If "DLINE LIST" is sent, the server sends back a list of our current DLINEs.`,
|
||||
},
|
||||
"help": {
|
||||
text: `HELP <argument>
|
||||
@ -216,6 +219,7 @@ supplied.`,
|
||||
"kline": {
|
||||
oper: true,
|
||||
text: `KLINE [ANDKILL] [MYSELF] [duration] <mask> [ON <server>] [reason [| oper reason]]
|
||||
KLINE LIST
|
||||
|
||||
Bans a mask from connecting to the server. If the duration is given then only for that
|
||||
long. The reason is shown to the user themselves, but everyone else will see a standard
|
||||
@ -237,7 +241,9 @@ from. If "MYSELF" is not given, trying to KLINE yourself will result in an error
|
||||
|
||||
ON <server> specifies that the ban is to be set on that specific server.
|
||||
|
||||
[reason] and [oper reason], if they exist, are separated by a vertical bar (|).`,
|
||||
[reason] and [oper reason], if they exist, are separated by a vertical bar (|).
|
||||
|
||||
If "KLINE LIST" is sent, the server sends back a list of our current KLINEs.`,
|
||||
},
|
||||
"list": {
|
||||
text: `LIST [<channel>{,<channel>}] [<elistcond>{,<elistcond>}]
|
||||
|
16
irc/kline.go
16
irc/kline.go
@ -127,6 +127,7 @@ func (km *KLineManager) CheckMasks(masks ...string) (isBanned bool, info *IPBanI
|
||||
}
|
||||
|
||||
// KLINE [ANDKILL] [MYSELF] [duration] <mask> [ON <server>] [reason [| oper reason]]
|
||||
// KLINE LIST
|
||||
func klineHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
||||
// check oper permissions
|
||||
if !client.class.Capabilities["oper:local_ban"] {
|
||||
@ -136,6 +137,21 @@ func klineHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
||||
|
||||
currentArg := 0
|
||||
|
||||
// if they say LIST, we just list the current klines
|
||||
if len(msg.Params) == currentArg+1 && strings.ToLower(msg.Params[currentArg]) == "list" {
|
||||
bans := server.klines.AllBans()
|
||||
|
||||
if len(bans) == 0 {
|
||||
client.Notice("No KLINEs have been set!")
|
||||
}
|
||||
|
||||
for key, info := range bans {
|
||||
client.Notice(fmt.Sprintf("Ban - %s - %s", key, info.BanMessage("%s")))
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// when setting a ban, if they say "ANDKILL" we should also kill all users who match it
|
||||
var andKill bool
|
||||
if len(msg.Params) > currentArg+1 && strings.ToLower(msg.Params[currentArg]) == "andkill" {
|
||||
|
Loading…
Reference in New Issue
Block a user