|
@@ -129,51 +129,6 @@ for the rejection.`,
|
129
|
129
|
maxParams: 2,
|
130
|
130
|
unsplitFinalParam: true,
|
131
|
131
|
},
|
132
|
|
- "forbid": {
|
133
|
|
- handler: hsForbidHandler,
|
134
|
|
- help: `Syntax: $bFORBID <user>$b
|
135
|
|
-
|
136
|
|
-FORBID prevents a user from using any vhost, including ones on the offer list.`,
|
137
|
|
- helpShort: `$bFORBID$b prevents a user from using vhosts.`,
|
138
|
|
- capabs: []string{"vhosts"},
|
139
|
|
- enabled: hostservEnabled,
|
140
|
|
- minParams: 1,
|
141
|
|
- maxParams: 1,
|
142
|
|
- },
|
143
|
|
- "permit": {
|
144
|
|
- handler: hsForbidHandler,
|
145
|
|
- help: `Syntax: $bPERMIT <user>$b
|
146
|
|
-
|
147
|
|
-PERMIT undoes FORBID, allowing the user to TAKE vhosts again.`,
|
148
|
|
- helpShort: `$bPERMIT$b allows a user to use vhosts again.`,
|
149
|
|
- capabs: []string{"vhosts"},
|
150
|
|
- enabled: hostservEnabled,
|
151
|
|
- minParams: 1,
|
152
|
|
- maxParams: 1,
|
153
|
|
- },
|
154
|
|
- "offerlist": {
|
155
|
|
- handler: hsOfferListHandler,
|
156
|
|
- help: `Syntax: $bOFFERLIST$b
|
157
|
|
-
|
158
|
|
-OFFERLIST lists vhosts that can be chosen without requiring operator approval;
|
159
|
|
-to use one of the listed vhosts, take it with /HOSTSERV TAKE.`,
|
160
|
|
- helpShort: `$bOFFERLIST$b lists vhosts that can be taken without operator approval.`,
|
161
|
|
- enabled: hostservEnabled,
|
162
|
|
- minParams: 0,
|
163
|
|
- maxParams: 0,
|
164
|
|
- },
|
165
|
|
- "take": {
|
166
|
|
- handler: hsTakeHandler,
|
167
|
|
- help: `Syntax: $bTAKE$b <vhost>
|
168
|
|
-
|
169
|
|
-TAKE sets your vhost to one of the vhosts in the server's offer list; to see
|
170
|
|
-the offered vhosts, use /HOSTSERV OFFERLIST.`,
|
171
|
|
- helpShort: `$bTAKE$b sets your vhost to one of the options from the offer list.`,
|
172
|
|
- enabled: hostservEnabled,
|
173
|
|
- authRequired: true,
|
174
|
|
- minParams: 1,
|
175
|
|
- maxParams: 1,
|
176
|
|
- },
|
177
|
132
|
"setcloaksecret": {
|
178
|
133
|
handler: hsSetCloakSecretHandler,
|
179
|
134
|
help: `Syntax: $bSETCLOAKSECRET$b <secret> [code]
|
|
@@ -238,8 +193,6 @@ func hsRequestHandler(server *Server, client *Client, command string, params []s
|
238
|
193
|
if err != nil {
|
239
|
194
|
if throttled, ok := err.(*vhostThrottleExceeded); ok {
|
240
|
195
|
hsNotice(rb, fmt.Sprintf(client.t("You must wait an additional %v before making another request"), throttled.timeRemaining))
|
241
|
|
- } else if err == errVhostsForbidden {
|
242
|
|
- hsNotice(rb, client.t("An administrator has denied you the ability to use vhosts"))
|
243
|
196
|
} else {
|
244
|
197
|
hsNotice(rb, client.t("An error occurred"))
|
245
|
198
|
}
|
|
@@ -276,11 +229,6 @@ func hsStatusHandler(server *Server, client *Client, command string, params []st
|
276
|
229
|
return
|
277
|
230
|
}
|
278
|
231
|
|
279
|
|
- if account.VHost.Forbidden {
|
280
|
|
- hsNotice(rb, client.t("An administrator has denied you the ability to use vhosts"))
|
281
|
|
- return
|
282
|
|
- }
|
283
|
|
-
|
284
|
232
|
if account.VHost.ApprovedVHost != "" {
|
285
|
233
|
hsNotice(rb, fmt.Sprintf(client.t("Account %[1]s has vhost: %[2]s"), accountName, account.VHost.ApprovedVHost))
|
286
|
234
|
if !account.VHost.Enabled {
|
|
@@ -382,70 +330,6 @@ func hsRejectHandler(server *Server, client *Client, command string, params []st
|
382
|
330
|
}
|
383
|
331
|
}
|
384
|
332
|
|
385
|
|
-func hsForbidHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
386
|
|
- user := params[0]
|
387
|
|
- forbidden := command == "forbid"
|
388
|
|
-
|
389
|
|
- _, err := server.accounts.VHostForbid(user, forbidden)
|
390
|
|
- if err == errAccountDoesNotExist {
|
391
|
|
- hsNotice(rb, client.t("No such account"))
|
392
|
|
- } else if err != nil {
|
393
|
|
- hsNotice(rb, client.t("An error occurred"))
|
394
|
|
- } else {
|
395
|
|
- if forbidden {
|
396
|
|
- hsNotice(rb, fmt.Sprintf(client.t("User %s is no longer allowed to use vhosts"), user))
|
397
|
|
- } else {
|
398
|
|
- hsNotice(rb, fmt.Sprintf(client.t("User %s is now allowed to use vhosts"), user))
|
399
|
|
- }
|
400
|
|
- }
|
401
|
|
-}
|
402
|
|
-
|
403
|
|
-func hsOfferListHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
404
|
|
- vhostConfig := server.Config().Accounts.VHosts
|
405
|
|
- if len(vhostConfig.OfferList) == 0 {
|
406
|
|
- if vhostConfig.UserRequests.Enabled {
|
407
|
|
- hsNotice(rb, client.t("The server does not offer any vhosts, but you can request one with /HOSTSERV REQUEST"))
|
408
|
|
- } else {
|
409
|
|
- hsNotice(rb, client.t("The server does not offer any vhosts"))
|
410
|
|
- }
|
411
|
|
- } else {
|
412
|
|
- hsNotice(rb, client.t("The following vhosts are available and can be chosen with /HOSTSERV TAKE:"))
|
413
|
|
- for _, vhost := range vhostConfig.OfferList {
|
414
|
|
- hsNotice(rb, vhost)
|
415
|
|
- }
|
416
|
|
- }
|
417
|
|
-}
|
418
|
|
-
|
419
|
|
-func hsTakeHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
420
|
|
- config := server.Config()
|
421
|
|
- vhost := params[0]
|
422
|
|
- found := false
|
423
|
|
- for _, offered := range config.Accounts.VHosts.OfferList {
|
424
|
|
- if offered == vhost {
|
425
|
|
- found = true
|
426
|
|
- }
|
427
|
|
- }
|
428
|
|
- if !found {
|
429
|
|
- hsNotice(rb, client.t("That vhost isn't being offered by the server"))
|
430
|
|
- return
|
431
|
|
- }
|
432
|
|
-
|
433
|
|
- account := client.Account()
|
434
|
|
- _, err := server.accounts.VHostTake(account, vhost, time.Duration(config.Accounts.VHosts.UserRequests.Cooldown))
|
435
|
|
- if err != nil {
|
436
|
|
- if throttled, ok := err.(*vhostThrottleExceeded); ok {
|
437
|
|
- hsNotice(rb, fmt.Sprintf(client.t("You must wait an additional %v before taking a vhost"), throttled.timeRemaining))
|
438
|
|
- } else if err == errVhostsForbidden {
|
439
|
|
- hsNotice(rb, client.t("An administrator has denied you the ability to use vhosts"))
|
440
|
|
- } else {
|
441
|
|
- hsNotice(rb, client.t("An error occurred"))
|
442
|
|
- }
|
443
|
|
- } else {
|
444
|
|
- hsNotice(rb, client.t("Successfully set vhost"))
|
445
|
|
- server.snomasks.Send(sno.LocalVhosts, fmt.Sprintf("Client %s (account %s) took vhost %s", client.Nick(), account, vhost))
|
446
|
|
- }
|
447
|
|
-}
|
448
|
|
-
|
449
|
333
|
func hsSetCloakSecretHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
450
|
334
|
secret := params[0]
|
451
|
335
|
expectedCode := utils.ConfirmationCode(secret, server.ctime)
|