|
@@ -152,16 +152,8 @@ func ubanAddHandler(client *Client, target ubanTarget, params []string, rb *Resp
|
152
|
152
|
case ubanNickmask:
|
153
|
153
|
ubanAddNickmask(client, target, duration, operReason, rb)
|
154
|
154
|
case ubanNick:
|
155
|
|
- account := target.nickOrMask
|
156
|
|
- err := client.server.accounts.Suspend(account, duration, client.Oper().Name, "UBAN")
|
157
|
|
- switch err {
|
158
|
|
- case nil:
|
159
|
|
- rb.Notice(fmt.Sprintf(client.t("Successfully suspended account %s"), account))
|
160
|
|
- case errAccountDoesNotExist:
|
161
|
|
- rb.Notice(client.t("No such account"))
|
162
|
|
- default:
|
163
|
|
- rb.Notice(client.t("An error occurred"))
|
164
|
|
- }
|
|
155
|
+ ubanAddAccount(client, target, duration, operReason, rb)
|
|
156
|
+
|
165
|
157
|
}
|
166
|
158
|
return false
|
167
|
159
|
}
|
|
@@ -227,6 +219,31 @@ func ubanAddNickmask(client *Client, target ubanTarget, duration time.Duration,
|
227
|
219
|
}
|
228
|
220
|
}
|
229
|
221
|
|
|
222
|
+func ubanAddAccount(client *Client, target ubanTarget, duration time.Duration, operReason string, rb *ResponseBuffer) {
|
|
223
|
+ account := target.nickOrMask
|
|
224
|
+ // TODO this doesn't enumerate all sessions if ForceNickEqualsAccount is disabled
|
|
225
|
+ var sessionData []SessionData
|
|
226
|
+ if mcl := client.server.clients.Get(account); mcl != nil {
|
|
227
|
+ sessionData, _ = mcl.AllSessionData(nil, true)
|
|
228
|
+ }
|
|
229
|
+
|
|
230
|
+ err := client.server.accounts.Suspend(account, duration, client.Oper().Name, operReason)
|
|
231
|
+ switch err {
|
|
232
|
+ case nil:
|
|
233
|
+ rb.Notice(fmt.Sprintf(client.t("Successfully suspended account %s"), account))
|
|
234
|
+ if len(sessionData) != 0 {
|
|
235
|
+ rb.Notice(fmt.Sprintf(client.t("Disconnected %d client(s) associated with the account, using the following IPs:"), len(sessionData)))
|
|
236
|
+ for i, d := range sessionData {
|
|
237
|
+ rb.Notice(fmt.Sprintf("%d. %s", i+1, d.ip.String()))
|
|
238
|
+ }
|
|
239
|
+ }
|
|
240
|
+ case errAccountDoesNotExist:
|
|
241
|
+ rb.Notice(client.t("No such account"))
|
|
242
|
+ default:
|
|
243
|
+ rb.Notice(client.t("An error occurred"))
|
|
244
|
+ }
|
|
245
|
+}
|
|
246
|
+
|
230
|
247
|
func ubanDelHandler(client *Client, target ubanTarget, params []string, rb *ResponseBuffer) bool {
|
231
|
248
|
var err error
|
232
|
249
|
var targetString string
|