Browse Source

add vhost snomasks

tags/v2.0.0-rc1
Shivaram Lingamneni 4 years ago
parent
commit
88d7e98011
3 changed files with 16 additions and 9 deletions
  1. 9
    5
      irc/hostserv.go
  2. 6
    3
      irc/sno/constants.go
  3. 1
    1
      oragono.yaml

+ 9
- 5
irc/hostserv.go View File

@@ -7,6 +7,8 @@ import (
7 7
 	"errors"
8 8
 	"fmt"
9 9
 	"regexp"
10
+
11
+	"github.com/oragono/oragono/irc/sno"
10 12
 )
11 13
 
12 14
 const hostservHelp = `HostServ lets you manage your vhost (i.e., the string displayed
@@ -225,7 +227,7 @@ func hsRequestHandler(server *Server, client *Client, command string, params []s
225 227
 		hsNotice(rb, client.t("Your vhost request will be reviewed by an administrator"))
226 228
 		chanMsg := fmt.Sprintf("Account %s requests vhost %s", accountName, vhost)
227 229
 		hsNotifyChannel(server, chanMsg)
228
-		// TODO send admins a snomask of some kind
230
+		server.snomasks.Send(sno.LocalVhosts, chanMsg)
229 231
 	}
230 232
 }
231 233
 
@@ -328,6 +330,7 @@ func hsApproveHandler(server *Server, client *Client, command string, params []s
328 330
 		hsNotice(rb, fmt.Sprintf(client.t("Successfully approved vhost request for %s"), user))
329 331
 		chanMsg := fmt.Sprintf("Oper %[1]s approved vhost %[2]s for account %[3]s", client.Nick(), vhostInfo.ApprovedVHost, user)
330 332
 		hsNotifyChannel(server, chanMsg)
333
+		server.snomasks.Send(sno.LocalVhosts, chanMsg)
331 334
 		for _, client := range server.accounts.AccountToClients(user) {
332 335
 			client.Notice(client.t("Your vhost request was approved by an administrator"))
333 336
 		}
@@ -348,6 +351,7 @@ func hsRejectHandler(server *Server, client *Client, command string, params []st
348 351
 		hsNotice(rb, fmt.Sprintf(client.t("Successfully rejected vhost request for %s"), user))
349 352
 		chanMsg := fmt.Sprintf("Oper %s rejected vhost %s for account %s, with the reason: %v", client.Nick(), vhostInfo.RejectedVHost, user, reason)
350 353
 		hsNotifyChannel(server, chanMsg)
354
+		server.snomasks.Send(sno.LocalVhosts, chanMsg)
351 355
 		for _, client := range server.accounts.AccountToClients(user) {
352 356
 			if reason == "" {
353 357
 				client.Notice("Your vhost request was rejected by an administrator")
@@ -406,7 +410,8 @@ func hsTakeHandler(server *Server, client *Client, command string, params []stri
406 410
 		return
407 411
 	}
408 412
 
409
-	_, err := server.accounts.VHostTake(client.Account(), vhost, config.Accounts.VHosts.UserRequests.Cooldown)
413
+	account := client.Account()
414
+	_, err := server.accounts.VHostTake(account, vhost, config.Accounts.VHosts.UserRequests.Cooldown)
410 415
 	if err != nil {
411 416
 		if throttled, ok := err.(*vhostThrottleExceeded); ok {
412 417
 			hsNotice(rb, fmt.Sprintf(client.t("You must wait an additional %v before taking a vhost"), throttled.timeRemaining))
@@ -415,9 +420,8 @@ func hsTakeHandler(server *Server, client *Client, command string, params []stri
415 420
 		} else {
416 421
 			hsNotice(rb, client.t("An error occurred"))
417 422
 		}
418
-	} else if vhost != "" {
419
-		hsNotice(rb, client.t("Successfully set vhost"))
420 423
 	} else {
421
-		hsNotice(rb, client.t("Successfully cleared vhost"))
424
+		hsNotice(rb, client.t("Successfully set vhost"))
425
+		server.snomasks.Send(sno.LocalVhosts, fmt.Sprintf("Client %s (account %s) took vhost %s", client.Nick(), account, vhost))
422 426
 	}
423 427
 }

+ 6
- 3
irc/sno/constants.go View File

@@ -9,7 +9,7 @@ type Mask rune
9 9
 
10 10
 // Notice mask types
11 11
 const (
12
-	LocalAccouncements Mask = 'a'
12
+	LocalAnnouncements Mask = 'a'
13 13
 	LocalConnects      Mask = 'c'
14 14
 	LocalChannels      Mask = 'j'
15 15
 	LocalKills         Mask = 'k'
@@ -19,12 +19,13 @@ const (
19 19
 	Stats              Mask = 't'
20 20
 	LocalAccounts      Mask = 'u'
21 21
 	LocalXline         Mask = 'x'
22
+	LocalVhosts        Mask = 'v'
22 23
 )
23 24
 
24 25
 var (
25 26
 	// NoticeMaskNames has readable names for our snomask types.
26 27
 	NoticeMaskNames = map[Mask]string{
27
-		LocalAccouncements: "ANNOUNCEMENT",
28
+		LocalAnnouncements: "ANNOUNCEMENT",
28 29
 		LocalConnects:      "CONNECT",
29 30
 		LocalChannels:      "CHANNEL",
30 31
 		LocalKills:         "KILL",
@@ -34,11 +35,12 @@ var (
34 35
 		Stats:              "STATS",
35 36
 		LocalAccounts:      "ACCOUNT",
36 37
 		LocalXline:         "XLINE",
38
+		LocalVhosts:        "VHOST",
37 39
 	}
38 40
 
39 41
 	// ValidMasks contains the snomasks that we support.
40 42
 	ValidMasks = map[Mask]bool{
41
-		LocalAccouncements: true,
43
+		LocalAnnouncements: true,
42 44
 		LocalConnects:      true,
43 45
 		LocalChannels:      true,
44 46
 		LocalKills:         true,
@@ -48,5 +50,6 @@ var (
48 50
 		Stats:              true,
49 51
 		LocalAccounts:      true,
50 52
 		LocalXline:         true,
53
+		LocalVhosts:        true,
51 54
 	}
52 55
 )

+ 1
- 1
oragono.yaml View File

@@ -466,7 +466,7 @@ opers:
466 466
         vhost: "n"
467 467
 
468 468
         # modes are the modes to auto-set upon opering-up
469
-        modes: +is acjknoqtux
469
+        modes: +is acjknoqtuxv
470 470
 
471 471
         # operators can be authenticated either by password (with the /OPER command),
472 472
         # or by certificate fingerprint, or both. if a password hash is set, then a

Loading…
Cancel
Save