3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-22 11:59:40 +01:00

add IP addresses to UBAN ADD <account> output

This commit is contained in:
Shivaram Lingamneni 2021-01-19 12:19:48 -05:00
parent bb5276553d
commit 44bfca80a7

View File

@ -152,16 +152,8 @@ func ubanAddHandler(client *Client, target ubanTarget, params []string, rb *Resp
case ubanNickmask:
ubanAddNickmask(client, target, duration, operReason, rb)
case ubanNick:
account := target.nickOrMask
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"))
}
ubanAddAccount(client, target, duration, operReason, rb)
}
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 {
var err error
var targetString string