mirror of
https://github.com/ergochat/ergo.git
synced 2025-02-16 21:50:39 +01:00
add IP addresses to UBAN ADD <account> output
This commit is contained in:
parent
bb5276553d
commit
44bfca80a7
37
irc/uban.go
37
irc/uban.go
@ -152,16 +152,8 @@ func ubanAddHandler(client *Client, target ubanTarget, params []string, rb *Resp
|
|||||||
case ubanNickmask:
|
case ubanNickmask:
|
||||||
ubanAddNickmask(client, target, duration, operReason, rb)
|
ubanAddNickmask(client, target, duration, operReason, rb)
|
||||||
case ubanNick:
|
case ubanNick:
|
||||||
account := target.nickOrMask
|
ubanAddAccount(client, target, duration, operReason, rb)
|
||||||
err := client.server.accounts.Suspend(account, duration, client.Oper().Name, "UBAN")
|
|
||||||
switch err {
|
|
||||||
case nil:
|
|
||||||
rb.Notice(fmt.Sprintf(client.t("Successfully suspended account %s"), account))
|
|
||||||
case errAccountDoesNotExist:
|
|
||||||
rb.Notice(client.t("No such account"))
|
|
||||||
default:
|
|
||||||
rb.Notice(client.t("An error occurred"))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -227,6 +219,31 @@ func ubanAddNickmask(client *Client, target ubanTarget, duration time.Duration,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ubanAddAccount(client *Client, target ubanTarget, duration time.Duration, operReason string, rb *ResponseBuffer) {
|
||||||
|
account := target.nickOrMask
|
||||||
|
// TODO this doesn't enumerate all sessions if ForceNickEqualsAccount is disabled
|
||||||
|
var sessionData []SessionData
|
||||||
|
if mcl := client.server.clients.Get(account); mcl != nil {
|
||||||
|
sessionData, _ = mcl.AllSessionData(nil, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
err := client.server.accounts.Suspend(account, duration, client.Oper().Name, operReason)
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
rb.Notice(fmt.Sprintf(client.t("Successfully suspended account %s"), account))
|
||||||
|
if len(sessionData) != 0 {
|
||||||
|
rb.Notice(fmt.Sprintf(client.t("Disconnected %d client(s) associated with the account, using the following IPs:"), len(sessionData)))
|
||||||
|
for i, d := range sessionData {
|
||||||
|
rb.Notice(fmt.Sprintf("%d. %s", i+1, d.ip.String()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case errAccountDoesNotExist:
|
||||||
|
rb.Notice(client.t("No such account"))
|
||||||
|
default:
|
||||||
|
rb.Notice(client.t("An error occurred"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func ubanDelHandler(client *Client, target ubanTarget, params []string, rb *ResponseBuffer) bool {
|
func ubanDelHandler(client *Client, target ubanTarget, params []string, rb *ResponseBuffer) bool {
|
||||||
var err error
|
var err error
|
||||||
var targetString string
|
var targetString string
|
||||||
|
Loading…
x
Reference in New Issue
Block a user