|
@@ -121,6 +121,51 @@ for the rejection.`,
|
121
|
121
|
maxParams: 2,
|
122
|
122
|
unsplitFinalParam: true,
|
123
|
123
|
},
|
|
124
|
+ "forbid": {
|
|
125
|
+ handler: hsForbidHandler,
|
|
126
|
+ help: `Syntax: $bFORBID <user>$b
|
|
127
|
+
|
|
128
|
+FORBID prevents a user from using any vhost, including ones on the offer list.`,
|
|
129
|
+ helpShort: `$bFORBID$b prevents a user from using vhosts.`,
|
|
130
|
+ capabs: []string{"vhosts"},
|
|
131
|
+ enabled: hostservEnabled,
|
|
132
|
+ minParams: 1,
|
|
133
|
+ maxParams: 1,
|
|
134
|
+ },
|
|
135
|
+ "permit": {
|
|
136
|
+ handler: hsForbidHandler,
|
|
137
|
+ help: `Syntax: $bPERMIT <user>$b
|
|
138
|
+
|
|
139
|
+PERMIT undoes FORBID, allowing the user to TAKE vhosts again.`,
|
|
140
|
+ helpShort: `$bPERMIT$b allows a user to use vhosts again.`,
|
|
141
|
+ capabs: []string{"vhosts"},
|
|
142
|
+ enabled: hostservEnabled,
|
|
143
|
+ minParams: 1,
|
|
144
|
+ maxParams: 1,
|
|
145
|
+ },
|
|
146
|
+ "offerlist": {
|
|
147
|
+ handler: hsOfferListHandler,
|
|
148
|
+ help: `Syntax: $bOFFERLIST$b
|
|
149
|
+
|
|
150
|
+OFFERLIST lists vhosts that can be chosen without requiring operator approval;
|
|
151
|
+to use one of the listed vhosts, take it with /HOSTSERV TAKE.`,
|
|
152
|
+ helpShort: `$bOFFERLIST$b lists vhosts that can be taken without operator approval.`,
|
|
153
|
+ enabled: hostservEnabled,
|
|
154
|
+ minParams: 0,
|
|
155
|
+ maxParams: 0,
|
|
156
|
+ },
|
|
157
|
+ "take": {
|
|
158
|
+ handler: hsTakeHandler,
|
|
159
|
+ help: `Syntax: $bTAKE$b <vhost>
|
|
160
|
+
|
|
161
|
+TAKE sets your vhost to one of the vhosts in the server's offer list; to see
|
|
162
|
+the offered vhosts, use /HOSTSERV OFFERLIST.`,
|
|
163
|
+ helpShort: `$bTAKE$b sets your vhost to one of the options from the offer list.`,
|
|
164
|
+ enabled: hostservEnabled,
|
|
165
|
+ authRequired: true,
|
|
166
|
+ minParams: 1,
|
|
167
|
+ maxParams: 1,
|
|
168
|
+ },
|
124
|
169
|
}
|
125
|
170
|
)
|
126
|
171
|
|
|
@@ -218,6 +263,11 @@ func hsStatusHandler(server *Server, client *Client, command string, params []st
|
218
|
263
|
return
|
219
|
264
|
}
|
220
|
265
|
|
|
266
|
+ if account.VHost.Forbidden {
|
|
267
|
+ hsNotice(rb, client.t("An administrator has denied you the ability to use vhosts"))
|
|
268
|
+ return
|
|
269
|
+ }
|
|
270
|
+
|
221
|
271
|
if account.VHost.ApprovedVHost != "" {
|
222
|
272
|
hsNotice(rb, fmt.Sprintf(client.t("Account %[1]s has vhost: %[2]s"), accountName, account.VHost.ApprovedVHost))
|
223
|
273
|
if !account.VHost.Enabled {
|
|
@@ -316,3 +366,60 @@ func hsRejectHandler(server *Server, client *Client, command string, params []st
|
316
|
366
|
}
|
317
|
367
|
}
|
318
|
368
|
}
|
|
369
|
+
|
|
370
|
+func hsForbidHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
|
371
|
+ user := params[0]
|
|
372
|
+ forbidden := command == "forbid"
|
|
373
|
+
|
|
374
|
+ _, err := server.accounts.VHostForbid(user, forbidden)
|
|
375
|
+ if err == errAccountDoesNotExist {
|
|
376
|
+ hsNotice(rb, client.t("No such account"))
|
|
377
|
+ } else if err != nil {
|
|
378
|
+ hsNotice(rb, client.t("An error occurred"))
|
|
379
|
+ } else {
|
|
380
|
+ if forbidden {
|
|
381
|
+ hsNotice(rb, fmt.Sprintf(client.t("Successfully forbidden vhosts to user %s"), user))
|
|
382
|
+ } else {
|
|
383
|
+ hsNotice(rb, fmt.Sprintf(client.t("Successfully permitted vhosts for user %s"), user))
|
|
384
|
+ }
|
|
385
|
+ }
|
|
386
|
+}
|
|
387
|
+
|
|
388
|
+func hsOfferListHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
|
389
|
+ vhostConfig := server.Config().Accounts.VHosts
|
|
390
|
+ if len(vhostConfig.OfferList) == 0 {
|
|
391
|
+ if vhostConfig.UserRequests.Enabled {
|
|
392
|
+ hsNotice(rb, client.t("The server does not offer any vhosts (but you can request one with /HOSTSERV REQUEST)"))
|
|
393
|
+ } else {
|
|
394
|
+ hsNotice(rb, client.t("The server does not offer any vhosts)"))
|
|
395
|
+ }
|
|
396
|
+ } else {
|
|
397
|
+ hsNotice(rb, client.t("The following vhosts are available and can be chosen with /HOSTSERV TAKE:"))
|
|
398
|
+ for i, vhost := range vhostConfig.OfferList {
|
|
399
|
+ hsNotice(rb, fmt.Sprintf("%d. %s", i+1, vhost))
|
|
400
|
+ }
|
|
401
|
+ }
|
|
402
|
+}
|
|
403
|
+
|
|
404
|
+func hsTakeHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
|
405
|
+ vhost := params[0]
|
|
406
|
+ found := false
|
|
407
|
+ for _, offered := range server.Config().Accounts.VHosts.OfferList {
|
|
408
|
+ if offered == vhost {
|
|
409
|
+ found = true
|
|
410
|
+ }
|
|
411
|
+ }
|
|
412
|
+ if !found {
|
|
413
|
+ hsNotice(rb, client.t("That vhost isn't being offered by the server"))
|
|
414
|
+ return
|
|
415
|
+ }
|
|
416
|
+
|
|
417
|
+ _, err := server.accounts.VHostSet(client.Account(), vhost)
|
|
418
|
+ if err != nil {
|
|
419
|
+ hsNotice(rb, client.t("An error occurred"))
|
|
420
|
+ } else if vhost != "" {
|
|
421
|
+ hsNotice(rb, client.t("Successfully set vhost"))
|
|
422
|
+ } else {
|
|
423
|
+ hsNotice(rb, client.t("Successfully cleared vhost"))
|
|
424
|
+ }
|
|
425
|
+}
|