|
@@ -36,10 +36,6 @@ func servCmdRequiresBouncerEnabled(config *Config) bool {
|
36
|
36
|
return config.Accounts.Multiclient.Enabled
|
37
|
37
|
}
|
38
|
38
|
|
39
|
|
-const (
|
40
|
|
- nsPrefix = "NickServ!NickServ@localhost"
|
41
|
|
-)
|
42
|
|
-
|
43
|
39
|
const nickservHelp = `NickServ lets you register, log in to, and manage an account.`
|
44
|
40
|
|
45
|
41
|
var (
|
|
@@ -361,14 +357,7 @@ Currently, you can only change the canonical casefolding of an account
|
361
|
357
|
}
|
362
|
358
|
)
|
363
|
359
|
|
364
|
|
-// nsNotice sends the client a notice from NickServ
|
365
|
|
-func nsNotice(rb *ResponseBuffer, text string) {
|
366
|
|
- // XXX i can't figure out how to use OragonoServices[servicename].prefix here
|
367
|
|
- // without creating a compile-time initialization loop
|
368
|
|
- rb.Add(nil, nsPrefix, "NOTICE", rb.target.Nick(), text)
|
369
|
|
-}
|
370
|
|
-
|
371
|
|
-func nsGetHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
|
360
|
+func nsGetHandler(service *ircService, server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
372
|
361
|
var account string
|
373
|
362
|
if command == "saget" {
|
374
|
363
|
account = params[0]
|
|
@@ -379,101 +368,101 @@ func nsGetHandler(server *Server, client *Client, command string, params []strin
|
379
|
368
|
|
380
|
369
|
accountData, err := server.accounts.LoadAccount(account)
|
381
|
370
|
if err == errAccountDoesNotExist {
|
382
|
|
- nsNotice(rb, client.t("No such account"))
|
|
371
|
+ service.Notice(rb, client.t("No such account"))
|
383
|
372
|
return
|
384
|
373
|
} else if err != nil {
|
385
|
|
- nsNotice(rb, client.t("Error loading account data"))
|
|
374
|
+ service.Notice(rb, client.t("Error loading account data"))
|
386
|
375
|
return
|
387
|
376
|
}
|
388
|
377
|
|
389
|
|
- displaySetting(params[0], accountData.Settings, client, rb)
|
|
378
|
+ displaySetting(service, params[0], accountData.Settings, client, rb)
|
390
|
379
|
}
|
391
|
380
|
|
392
|
|
-func displaySetting(settingName string, settings AccountSettings, client *Client, rb *ResponseBuffer) {
|
|
381
|
+func displaySetting(service *ircService, settingName string, settings AccountSettings, client *Client, rb *ResponseBuffer) {
|
393
|
382
|
config := client.server.Config()
|
394
|
383
|
switch strings.ToLower(settingName) {
|
395
|
384
|
case "enforce":
|
396
|
385
|
storedValue := settings.NickEnforcement
|
397
|
386
|
serializedStoredValue := nickReservationToString(storedValue)
|
398
|
|
- nsNotice(rb, fmt.Sprintf(client.t("Your stored nickname enforcement setting is: %s"), serializedStoredValue))
|
|
387
|
+ service.Notice(rb, fmt.Sprintf(client.t("Your stored nickname enforcement setting is: %s"), serializedStoredValue))
|
399
|
388
|
serializedActualValue := nickReservationToString(configuredEnforcementMethod(config, storedValue))
|
400
|
|
- nsNotice(rb, fmt.Sprintf(client.t("Given current server settings, your nickname is enforced with: %s"), serializedActualValue))
|
|
389
|
+ service.Notice(rb, fmt.Sprintf(client.t("Given current server settings, your nickname is enforced with: %s"), serializedActualValue))
|
401
|
390
|
case "autoreplay-lines":
|
402
|
391
|
if settings.AutoreplayLines == nil {
|
403
|
|
- nsNotice(rb, fmt.Sprintf(client.t("You will receive the server default of %d lines of autoreplayed history"), config.History.AutoreplayOnJoin))
|
|
392
|
+ service.Notice(rb, fmt.Sprintf(client.t("You will receive the server default of %d lines of autoreplayed history"), config.History.AutoreplayOnJoin))
|
404
|
393
|
} else {
|
405
|
|
- nsNotice(rb, fmt.Sprintf(client.t("You will receive %d lines of autoreplayed history"), *settings.AutoreplayLines))
|
|
394
|
+ service.Notice(rb, fmt.Sprintf(client.t("You will receive %d lines of autoreplayed history"), *settings.AutoreplayLines))
|
406
|
395
|
}
|
407
|
396
|
case "replay-joins":
|
408
|
397
|
switch settings.ReplayJoins {
|
409
|
398
|
case ReplayJoinsCommandsOnly:
|
410
|
|
- nsNotice(rb, client.t("You will see JOINs and PARTs in /HISTORY output, but not in autoreplay"))
|
|
399
|
+ service.Notice(rb, client.t("You will see JOINs and PARTs in /HISTORY output, but not in autoreplay"))
|
411
|
400
|
case ReplayJoinsAlways:
|
412
|
|
- nsNotice(rb, client.t("You will see JOINs and PARTs in /HISTORY output and in autoreplay"))
|
|
401
|
+ service.Notice(rb, client.t("You will see JOINs and PARTs in /HISTORY output and in autoreplay"))
|
413
|
402
|
case ReplayJoinsNever:
|
414
|
|
- nsNotice(rb, client.t("You will not see JOINs and PARTs in /HISTORY output or in autoreplay"))
|
|
403
|
+ service.Notice(rb, client.t("You will not see JOINs and PARTs in /HISTORY output or in autoreplay"))
|
415
|
404
|
}
|
416
|
405
|
case "multiclient":
|
417
|
406
|
if !config.Accounts.Multiclient.Enabled {
|
418
|
|
- nsNotice(rb, client.t("This feature has been disabled by the server administrators"))
|
|
407
|
+ service.Notice(rb, client.t("This feature has been disabled by the server administrators"))
|
419
|
408
|
} else {
|
420
|
409
|
switch settings.AllowBouncer {
|
421
|
410
|
case MulticlientAllowedServerDefault:
|
422
|
411
|
if config.Accounts.Multiclient.AllowedByDefault {
|
423
|
|
- nsNotice(rb, client.t("Multiclient functionality is currently enabled for your account, but you can opt out"))
|
|
412
|
+ service.Notice(rb, client.t("Multiclient functionality is currently enabled for your account, but you can opt out"))
|
424
|
413
|
} else {
|
425
|
|
- nsNotice(rb, client.t("Multiclient functionality is currently disabled for your account, but you can opt in"))
|
|
414
|
+ service.Notice(rb, client.t("Multiclient functionality is currently disabled for your account, but you can opt in"))
|
426
|
415
|
}
|
427
|
416
|
case MulticlientDisallowedByUser:
|
428
|
|
- nsNotice(rb, client.t("Multiclient functionality is currently disabled for your account"))
|
|
417
|
+ service.Notice(rb, client.t("Multiclient functionality is currently disabled for your account"))
|
429
|
418
|
case MulticlientAllowedByUser:
|
430
|
|
- nsNotice(rb, client.t("Multiclient functionality is currently enabled for your account"))
|
|
419
|
+ service.Notice(rb, client.t("Multiclient functionality is currently enabled for your account"))
|
431
|
420
|
}
|
432
|
421
|
}
|
433
|
422
|
case "always-on":
|
434
|
423
|
stored := settings.AlwaysOn
|
435
|
424
|
actual := persistenceEnabled(config.Accounts.Multiclient.AlwaysOn, stored)
|
436
|
|
- nsNotice(rb, fmt.Sprintf(client.t("Your stored always-on setting is: %s"), persistentStatusToString(stored)))
|
|
425
|
+ service.Notice(rb, fmt.Sprintf(client.t("Your stored always-on setting is: %s"), persistentStatusToString(stored)))
|
437
|
426
|
if actual {
|
438
|
|
- nsNotice(rb, client.t("Given current server settings, your client is always-on"))
|
|
427
|
+ service.Notice(rb, client.t("Given current server settings, your client is always-on"))
|
439
|
428
|
} else {
|
440
|
|
- nsNotice(rb, client.t("Given current server settings, your client is not always-on"))
|
|
429
|
+ service.Notice(rb, client.t("Given current server settings, your client is not always-on"))
|
441
|
430
|
}
|
442
|
431
|
case "autoreplay-missed":
|
443
|
432
|
stored := settings.AutoreplayMissed
|
444
|
433
|
if stored {
|
445
|
434
|
alwaysOn := persistenceEnabled(config.Accounts.Multiclient.AlwaysOn, settings.AlwaysOn)
|
446
|
435
|
if alwaysOn {
|
447
|
|
- nsNotice(rb, client.t("Autoreplay of missed messages is enabled"))
|
|
436
|
+ service.Notice(rb, client.t("Autoreplay of missed messages is enabled"))
|
448
|
437
|
} else {
|
449
|
|
- nsNotice(rb, client.t("You have enabled autoreplay of missed messages, but you can't receive them because your client isn't set to always-on"))
|
|
438
|
+ service.Notice(rb, client.t("You have enabled autoreplay of missed messages, but you can't receive them because your client isn't set to always-on"))
|
450
|
439
|
}
|
451
|
440
|
} else {
|
452
|
|
- nsNotice(rb, client.t("Your account is not configured to receive autoreplayed missed messages"))
|
|
441
|
+ service.Notice(rb, client.t("Your account is not configured to receive autoreplayed missed messages"))
|
453
|
442
|
}
|
454
|
443
|
case "auto-away":
|
455
|
444
|
stored := settings.AutoAway
|
456
|
445
|
alwaysOn := persistenceEnabled(config.Accounts.Multiclient.AlwaysOn, settings.AlwaysOn)
|
457
|
446
|
actual := persistenceEnabled(config.Accounts.Multiclient.AutoAway, settings.AutoAway)
|
458
|
|
- nsNotice(rb, fmt.Sprintf(client.t("Your stored auto-away setting is: %s"), persistentStatusToString(stored)))
|
|
447
|
+ service.Notice(rb, fmt.Sprintf(client.t("Your stored auto-away setting is: %s"), persistentStatusToString(stored)))
|
459
|
448
|
if actual && alwaysOn {
|
460
|
|
- nsNotice(rb, client.t("Given current server settings, auto-away is enabled for your client"))
|
|
449
|
+ service.Notice(rb, client.t("Given current server settings, auto-away is enabled for your client"))
|
461
|
450
|
} else if actual && !alwaysOn {
|
462
|
|
- nsNotice(rb, client.t("Because your client is not always-on, auto-away is disabled"))
|
|
451
|
+ service.Notice(rb, client.t("Because your client is not always-on, auto-away is disabled"))
|
463
|
452
|
} else if !actual {
|
464
|
|
- nsNotice(rb, client.t("Given current server settings, auto-away is disabled for your client"))
|
|
453
|
+ service.Notice(rb, client.t("Given current server settings, auto-away is disabled for your client"))
|
465
|
454
|
}
|
466
|
455
|
case "dm-history":
|
467
|
456
|
effectiveValue := historyEnabled(config.History.Persistent.DirectMessages, settings.DMHistory)
|
468
|
|
- nsNotice(rb, fmt.Sprintf(client.t("Your stored direct message history setting is: %s"), historyStatusToString(settings.DMHistory)))
|
469
|
|
- nsNotice(rb, fmt.Sprintf(client.t("Given current server settings, your direct message history setting is: %s"), historyStatusToString(effectiveValue)))
|
|
457
|
+ service.Notice(rb, fmt.Sprintf(client.t("Your stored direct message history setting is: %s"), historyStatusToString(settings.DMHistory)))
|
|
458
|
+ service.Notice(rb, fmt.Sprintf(client.t("Given current server settings, your direct message history setting is: %s"), historyStatusToString(effectiveValue)))
|
470
|
459
|
|
471
|
460
|
default:
|
472
|
|
- nsNotice(rb, client.t("No such setting"))
|
|
461
|
+ service.Notice(rb, client.t("No such setting"))
|
473
|
462
|
}
|
474
|
463
|
}
|
475
|
464
|
|
476
|
|
-func nsSetHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
|
465
|
+func nsSetHandler(service *ircService, server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
477
|
466
|
var account string
|
478
|
467
|
if command == "saset" {
|
479
|
468
|
account = params[0]
|
|
@@ -487,7 +476,7 @@ func nsSetHandler(server *Server, client *Client, command string, params []strin
|
487
|
476
|
var err error
|
488
|
477
|
switch strings.ToLower(params[0]) {
|
489
|
478
|
case "pass", "password":
|
490
|
|
- nsNotice(rb, client.t("To change a password, use the PASSWD command. For details, /msg NickServ HELP PASSWD"))
|
|
479
|
+ service.Notice(rb, client.t("To change a password, use the PASSWD command. For details, /msg NickServ HELP PASSWD"))
|
491
|
480
|
return
|
492
|
481
|
case "enforce":
|
493
|
482
|
var method NickEnforcementMethod
|
|
@@ -612,19 +601,19 @@ func nsSetHandler(server *Server, client *Client, command string, params []strin
|
612
|
601
|
|
613
|
602
|
switch err {
|
614
|
603
|
case nil:
|
615
|
|
- nsNotice(rb, client.t("Successfully changed your account settings"))
|
616
|
|
- displaySetting(params[0], finalSettings, client, rb)
|
|
604
|
+ service.Notice(rb, client.t("Successfully changed your account settings"))
|
|
605
|
+ displaySetting(service, params[0], finalSettings, client, rb)
|
617
|
606
|
case errInvalidParams, errAccountDoesNotExist, errFeatureDisabled, errAccountUnverified, errAccountUpdateFailed:
|
618
|
|
- nsNotice(rb, client.t(err.Error()))
|
|
607
|
+ service.Notice(rb, client.t(err.Error()))
|
619
|
608
|
case errNickAccountMismatch:
|
620
|
|
- nsNotice(rb, fmt.Sprintf(client.t("Your nickname must match your account name %s exactly to modify this setting. Try changing it with /NICK, or logging out and back in with the correct nickname."), client.AccountName()))
|
|
609
|
+ service.Notice(rb, fmt.Sprintf(client.t("Your nickname must match your account name %s exactly to modify this setting. Try changing it with /NICK, or logging out and back in with the correct nickname."), client.AccountName()))
|
621
|
610
|
default:
|
622
|
611
|
// unknown error
|
623
|
|
- nsNotice(rb, client.t("An error occurred"))
|
|
612
|
+ service.Notice(rb, client.t("An error occurred"))
|
624
|
613
|
}
|
625
|
614
|
}
|
626
|
615
|
|
627
|
|
-func nsDropHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
|
616
|
+func nsDropHandler(service *ircService, server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
628
|
617
|
sadrop := command == "sadrop"
|
629
|
618
|
var nick string
|
630
|
619
|
if len(params) > 0 {
|
|
@@ -635,28 +624,28 @@ func nsDropHandler(server *Server, client *Client, command string, params []stri
|
635
|
624
|
|
636
|
625
|
err := server.accounts.SetNickReserved(client, nick, sadrop, false)
|
637
|
626
|
if err == nil {
|
638
|
|
- nsNotice(rb, fmt.Sprintf(client.t("Successfully ungrouped nick %s with your account"), nick))
|
|
627
|
+ service.Notice(rb, fmt.Sprintf(client.t("Successfully ungrouped nick %s with your account"), nick))
|
639
|
628
|
} else if err == errAccountNotLoggedIn {
|
640
|
|
- nsNotice(rb, client.t("You're not logged into an account"))
|
|
629
|
+ service.Notice(rb, client.t("You're not logged into an account"))
|
641
|
630
|
} else if err == errAccountCantDropPrimaryNick {
|
642
|
|
- nsNotice(rb, client.t("You can't ungroup your primary nickname (try unregistering your account instead)"))
|
|
631
|
+ service.Notice(rb, client.t("You can't ungroup your primary nickname (try unregistering your account instead)"))
|
643
|
632
|
} else {
|
644
|
|
- nsNotice(rb, client.t("Could not ungroup nick"))
|
|
633
|
+ service.Notice(rb, client.t("Could not ungroup nick"))
|
645
|
634
|
}
|
646
|
635
|
}
|
647
|
636
|
|
648
|
|
-func nsGhostHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
|
637
|
+func nsGhostHandler(service *ircService, server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
649
|
638
|
nick := params[0]
|
650
|
639
|
|
651
|
640
|
ghost := server.clients.Get(nick)
|
652
|
641
|
if ghost == nil {
|
653
|
|
- nsNotice(rb, client.t("No such nick"))
|
|
642
|
+ service.Notice(rb, client.t("No such nick"))
|
654
|
643
|
return
|
655
|
644
|
} else if ghost == client {
|
656
|
|
- nsNotice(rb, client.t("You can't GHOST yourself (try /QUIT instead)"))
|
|
645
|
+ service.Notice(rb, client.t("You can't GHOST yourself (try /QUIT instead)"))
|
657
|
646
|
return
|
658
|
647
|
} else if ghost.AlwaysOn() {
|
659
|
|
- nsNotice(rb, client.t("You can't GHOST an always-on client"))
|
|
648
|
+ service.Notice(rb, client.t("You can't GHOST an always-on client"))
|
660
|
649
|
return
|
661
|
650
|
}
|
662
|
651
|
|
|
@@ -667,7 +656,7 @@ func nsGhostHandler(server *Server, client *Client, command string, params []str
|
667
|
656
|
authorized = (server.accounts.NickToAccount(nick) == account) || (ghost.Account() == account)
|
668
|
657
|
}
|
669
|
658
|
if !authorized {
|
670
|
|
- nsNotice(rb, client.t("You don't own that nick"))
|
|
659
|
+ service.Notice(rb, client.t("You don't own that nick"))
|
671
|
660
|
return
|
672
|
661
|
}
|
673
|
662
|
|
|
@@ -675,31 +664,31 @@ func nsGhostHandler(server *Server, client *Client, command string, params []str
|
675
|
664
|
ghost.destroy(nil)
|
676
|
665
|
}
|
677
|
666
|
|
678
|
|
-func nsGroupHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
|
667
|
+func nsGroupHandler(service *ircService, server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
679
|
668
|
nick := client.Nick()
|
680
|
669
|
err := server.accounts.SetNickReserved(client, nick, false, true)
|
681
|
670
|
if err == nil {
|
682
|
|
- nsNotice(rb, fmt.Sprintf(client.t("Successfully grouped nick %s with your account"), nick))
|
|
671
|
+ service.Notice(rb, fmt.Sprintf(client.t("Successfully grouped nick %s with your account"), nick))
|
683
|
672
|
} else if err == errAccountTooManyNicks {
|
684
|
|
- nsNotice(rb, client.t("You have too many nicks reserved already (you can remove some with /NS DROP)"))
|
|
673
|
+ service.Notice(rb, client.t("You have too many nicks reserved already (you can remove some with /NS DROP)"))
|
685
|
674
|
} else if err == errNicknameReserved {
|
686
|
|
- nsNotice(rb, client.t("That nickname is already reserved by someone else"))
|
|
675
|
+ service.Notice(rb, client.t("That nickname is already reserved by someone else"))
|
687
|
676
|
} else {
|
688
|
|
- nsNotice(rb, client.t("Error reserving nickname"))
|
|
677
|
+ service.Notice(rb, client.t("Error reserving nickname"))
|
689
|
678
|
}
|
690
|
679
|
}
|
691
|
680
|
|
692
|
|
-func nsLoginThrottleCheck(client *Client, rb *ResponseBuffer) (success bool) {
|
|
681
|
+func nsLoginThrottleCheck(service *ircService, client *Client, rb *ResponseBuffer) (success bool) {
|
693
|
682
|
throttled, remainingTime := client.checkLoginThrottle()
|
694
|
683
|
if throttled {
|
695
|
|
- nsNotice(rb, fmt.Sprintf(client.t("Please wait at least %v and try again"), remainingTime))
|
|
684
|
+ service.Notice(rb, fmt.Sprintf(client.t("Please wait at least %v and try again"), remainingTime))
|
696
|
685
|
}
|
697
|
686
|
return !throttled
|
698
|
687
|
}
|
699
|
688
|
|
700
|
|
-func nsIdentifyHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
|
689
|
+func nsIdentifyHandler(service *ircService, server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
701
|
690
|
if client.LoggedIntoAccount() {
|
702
|
|
- nsNotice(rb, client.t("You're already logged into an account"))
|
|
691
|
+ service.Notice(rb, client.t("You're already logged into an account"))
|
703
|
692
|
return
|
704
|
693
|
}
|
705
|
694
|
|
|
@@ -735,7 +724,7 @@ func nsIdentifyHandler(server *Server, client *Client, command string, params []
|
735
|
724
|
|
736
|
725
|
nickFixupFailed := false
|
737
|
726
|
if loginSuccessful {
|
738
|
|
- if !fixupNickEqualsAccount(client, rb, server.Config()) {
|
|
727
|
+ if !fixupNickEqualsAccount(client, rb, server.Config(), service.prefix) {
|
739
|
728
|
loginSuccessful = false
|
740
|
729
|
// fixupNickEqualsAccount sends its own error message, don't send another
|
741
|
730
|
nickFixupFailed = true
|
|
@@ -743,15 +732,15 @@ func nsIdentifyHandler(server *Server, client *Client, command string, params []
|
743
|
732
|
}
|
744
|
733
|
|
745
|
734
|
if loginSuccessful {
|
746
|
|
- sendSuccessfulAccountAuth(client, rb, true, true)
|
|
735
|
+ sendSuccessfulAccountAuth(service, client, rb, true)
|
747
|
736
|
} else if !nickFixupFailed {
|
748
|
|
- nsNotice(rb, fmt.Sprintf(client.t("Authentication failed: %s"), authErrorToMessage(server, err)))
|
|
737
|
+ service.Notice(rb, fmt.Sprintf(client.t("Authentication failed: %s"), authErrorToMessage(server, err)))
|
749
|
738
|
}
|
750
|
739
|
}
|
751
|
740
|
|
752
|
|
-func nsListHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
|
741
|
+func nsListHandler(service *ircService, server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
753
|
742
|
if !client.HasRoleCapabs("accreg") {
|
754
|
|
- nsNotice(rb, client.t("Insufficient privileges"))
|
|
743
|
+ service.Notice(rb, client.t("Insufficient privileges"))
|
755
|
744
|
return
|
756
|
745
|
}
|
757
|
746
|
|
|
@@ -760,26 +749,26 @@ func nsListHandler(server *Server, client *Client, command string, params []stri
|
760
|
749
|
var err error
|
761
|
750
|
searchRegex, err = regexp.Compile(params[0])
|
762
|
751
|
if err != nil {
|
763
|
|
- nsNotice(rb, client.t("Invalid regex"))
|
|
752
|
+ service.Notice(rb, client.t("Invalid regex"))
|
764
|
753
|
return
|
765
|
754
|
}
|
766
|
755
|
}
|
767
|
756
|
|
768
|
|
- nsNotice(rb, ircfmt.Unescape(client.t("*** $bNickServ LIST$b ***")))
|
|
757
|
+ service.Notice(rb, ircfmt.Unescape(client.t("*** $bNickServ LIST$b ***")))
|
769
|
758
|
|
770
|
759
|
nicks := server.accounts.AllNicks()
|
771
|
760
|
for _, nick := range nicks {
|
772
|
761
|
if searchRegex == nil || searchRegex.MatchString(nick) {
|
773
|
|
- nsNotice(rb, fmt.Sprintf(" %s", nick))
|
|
762
|
+ service.Notice(rb, fmt.Sprintf(" %s", nick))
|
774
|
763
|
}
|
775
|
764
|
}
|
776
|
765
|
|
777
|
|
- nsNotice(rb, ircfmt.Unescape(client.t("*** $bEnd of NickServ LIST$b ***")))
|
|
766
|
+ service.Notice(rb, ircfmt.Unescape(client.t("*** $bEnd of NickServ LIST$b ***")))
|
778
|
767
|
}
|
779
|
768
|
|
780
|
|
-func nsInfoHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
|
769
|
+func nsInfoHandler(service *ircService, server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
781
|
770
|
if !server.Config().Accounts.AuthenticationEnabled && !client.HasRoleCapabs("accreg") {
|
782
|
|
- nsNotice(rb, client.t("This command has been disabled by the server administrators"))
|
|
771
|
+ service.Notice(rb, client.t("This command has been disabled by the server administrators"))
|
783
|
772
|
return
|
784
|
773
|
}
|
785
|
774
|
|
|
@@ -789,7 +778,7 @@ func nsInfoHandler(server *Server, client *Client, command string, params []stri
|
789
|
778
|
if server.Config().Accounts.NickReservation.Enabled {
|
790
|
779
|
accountName = server.accounts.NickToAccount(nick)
|
791
|
780
|
if accountName == "" {
|
792
|
|
- nsNotice(rb, client.t("That nickname is not registered"))
|
|
781
|
+ service.Notice(rb, client.t("That nickname is not registered"))
|
793
|
782
|
return
|
794
|
783
|
}
|
795
|
784
|
} else {
|
|
@@ -798,33 +787,33 @@ func nsInfoHandler(server *Server, client *Client, command string, params []stri
|
798
|
787
|
} else {
|
799
|
788
|
accountName = client.Account()
|
800
|
789
|
if accountName == "" {
|
801
|
|
- nsNotice(rb, client.t("You're not logged into an account"))
|
|
790
|
+ service.Notice(rb, client.t("You're not logged into an account"))
|
802
|
791
|
return
|
803
|
792
|
}
|
804
|
793
|
}
|
805
|
794
|
|
806
|
795
|
account, err := server.accounts.LoadAccount(accountName)
|
807
|
796
|
if err != nil || !account.Verified {
|
808
|
|
- nsNotice(rb, client.t("Account does not exist"))
|
|
797
|
+ service.Notice(rb, client.t("Account does not exist"))
|
809
|
798
|
return
|
810
|
799
|
}
|
811
|
800
|
|
812
|
|
- nsNotice(rb, fmt.Sprintf(client.t("Account: %s"), account.Name))
|
|
801
|
+ service.Notice(rb, fmt.Sprintf(client.t("Account: %s"), account.Name))
|
813
|
802
|
registeredAt := account.RegisteredAt.Format(time.RFC1123)
|
814
|
|
- nsNotice(rb, fmt.Sprintf(client.t("Registered at: %s"), registeredAt))
|
|
803
|
+ service.Notice(rb, fmt.Sprintf(client.t("Registered at: %s"), registeredAt))
|
815
|
804
|
// TODO nicer formatting for this
|
816
|
805
|
for _, nick := range account.AdditionalNicks {
|
817
|
|
- nsNotice(rb, fmt.Sprintf(client.t("Additional grouped nick: %s"), nick))
|
|
806
|
+ service.Notice(rb, fmt.Sprintf(client.t("Additional grouped nick: %s"), nick))
|
818
|
807
|
}
|
819
|
808
|
for _, channel := range server.accounts.ChannelsForAccount(accountName) {
|
820
|
|
- nsNotice(rb, fmt.Sprintf(client.t("Registered channel: %s"), channel))
|
|
809
|
+ service.Notice(rb, fmt.Sprintf(client.t("Registered channel: %s"), channel))
|
821
|
810
|
}
|
822
|
811
|
if account.Suspended != nil {
|
823
|
|
- nsNotice(rb, suspensionToString(client, *account.Suspended))
|
|
812
|
+ service.Notice(rb, suspensionToString(client, *account.Suspended))
|
824
|
813
|
}
|
825
|
814
|
}
|
826
|
815
|
|
827
|
|
-func nsRegisterHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
|
816
|
+func nsRegisterHandler(service *ircService, server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
828
|
817
|
details := client.Details()
|
829
|
818
|
passphrase := params[0]
|
830
|
819
|
var email string
|
|
@@ -835,7 +824,7 @@ func nsRegisterHandler(server *Server, client *Client, command string, params []
|
835
|
824
|
certfp := rb.session.certfp
|
836
|
825
|
if passphrase == "*" {
|
837
|
826
|
if certfp == "" {
|
838
|
|
- nsNotice(rb, client.t("You must be connected with TLS and a client certificate to do this"))
|
|
827
|
+ service.Notice(rb, client.t("You must be connected with TLS and a client certificate to do this"))
|
839
|
828
|
return
|
840
|
829
|
} else {
|
841
|
830
|
passphrase = ""
|
|
@@ -845,12 +834,12 @@ func nsRegisterHandler(server *Server, client *Client, command string, params []
|
845
|
834
|
if passphrase != "" {
|
846
|
835
|
cfPassphrase, err := Casefold(passphrase)
|
847
|
836
|
if err == nil && cfPassphrase == details.nickCasefolded {
|
848
|
|
- nsNotice(rb, client.t("Usage: REGISTER <passphrase> [email]")) // #1179
|
|
837
|
+ service.Notice(rb, client.t("Usage: REGISTER <passphrase> [email]")) // #1179
|
849
|
838
|
return
|
850
|
839
|
}
|
851
|
840
|
}
|
852
|
841
|
|
853
|
|
- if !nsLoginThrottleCheck(client, rb) {
|
|
842
|
+ if !nsLoginThrottleCheck(service, client, rb) {
|
854
|
843
|
return
|
855
|
844
|
}
|
856
|
845
|
|
|
@@ -859,7 +848,7 @@ func nsRegisterHandler(server *Server, client *Client, command string, params []
|
859
|
848
|
if config.Accounts.NickReservation.ForceGuestFormat {
|
860
|
849
|
matches := config.Accounts.NickReservation.guestRegexp.FindStringSubmatch(account)
|
861
|
850
|
if matches == nil || len(matches) < 2 {
|
862
|
|
- nsNotice(rb, client.t("Erroneous nickname"))
|
|
851
|
+ service.Notice(rb, client.t("Erroneous nickname"))
|
863
|
852
|
return
|
864
|
853
|
}
|
865
|
854
|
account = matches[1]
|
|
@@ -867,7 +856,7 @@ func nsRegisterHandler(server *Server, client *Client, command string, params []
|
867
|
856
|
|
868
|
857
|
callbackNamespace, callbackValue, validationErr := parseCallback(email, config)
|
869
|
858
|
if validationErr != nil {
|
870
|
|
- nsNotice(rb, client.t("Registration requires a valid e-mail address"))
|
|
859
|
+ service.Notice(rb, client.t("Registration requires a valid e-mail address"))
|
871
|
860
|
return
|
872
|
861
|
}
|
873
|
862
|
|
|
@@ -875,22 +864,22 @@ func nsRegisterHandler(server *Server, client *Client, command string, params []
|
875
|
864
|
if err == nil {
|
876
|
865
|
if callbackNamespace == "*" {
|
877
|
866
|
err = server.accounts.Verify(client, account, "")
|
878
|
|
- if err == nil && fixupNickEqualsAccount(client, rb, config) {
|
879
|
|
- sendSuccessfulRegResponse(client, rb, true)
|
|
867
|
+ if err == nil && fixupNickEqualsAccount(client, rb, config, service.prefix) {
|
|
868
|
+ sendSuccessfulRegResponse(service, client, rb)
|
880
|
869
|
}
|
881
|
870
|
} else {
|
882
|
871
|
messageTemplate := client.t("Account created, pending verification; verification code has been sent to %s")
|
883
|
872
|
message := fmt.Sprintf(messageTemplate, callbackValue)
|
884
|
|
- nsNotice(rb, message)
|
|
873
|
+ service.Notice(rb, message)
|
885
|
874
|
}
|
886
|
875
|
} else {
|
887
|
876
|
// details could not be stored and relevant numerics have been dispatched, abort
|
888
|
877
|
message := registrationErrorToMessage(err)
|
889
|
|
- nsNotice(rb, client.t(message))
|
|
878
|
+ service.Notice(rb, client.t(message))
|
890
|
879
|
}
|
891
|
880
|
}
|
892
|
881
|
|
893
|
|
-func nsSaregisterHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
|
882
|
+func nsSaregisterHandler(service *ircService, server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
894
|
883
|
var account, passphrase string
|
895
|
884
|
account = params[0]
|
896
|
885
|
if 1 < len(params) && params[1] != "*" {
|
|
@@ -908,14 +897,14 @@ func nsSaregisterHandler(server *Server, client *Client, command string, params
|
908
|
897
|
server.logger.Error("services", "unknown error from saregister", err.Error())
|
909
|
898
|
errMsg = client.t("Could not register")
|
910
|
899
|
}
|
911
|
|
- nsNotice(rb, errMsg)
|
|
900
|
+ service.Notice(rb, errMsg)
|
912
|
901
|
} else {
|
913
|
|
- nsNotice(rb, fmt.Sprintf(client.t("Successfully registered account %s"), account))
|
|
902
|
+ service.Notice(rb, fmt.Sprintf(client.t("Successfully registered account %s"), account))
|
914
|
903
|
server.snomasks.Send(sno.LocalAccounts, fmt.Sprintf(ircfmt.Unescape("Operator $c[grey][$r%s$c[grey]] registered account $c[grey][$r%s$c[grey]] with SAREGISTER"), client.Oper().Name, account))
|
915
|
904
|
}
|
916
|
905
|
}
|
917
|
906
|
|
918
|
|
-func nsUnregisterHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
|
907
|
+func nsUnregisterHandler(service *ircService, server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
919
|
908
|
erase := command == "erase"
|
920
|
909
|
|
921
|
910
|
username := params[0]
|
|
@@ -925,7 +914,7 @@ func nsUnregisterHandler(server *Server, client *Client, command string, params
|
925
|
914
|
}
|
926
|
915
|
|
927
|
916
|
if username == "" {
|
928
|
|
- nsNotice(rb, client.t("You must specify an account"))
|
|
917
|
+ service.Notice(rb, client.t("You must specify an account"))
|
929
|
918
|
return
|
930
|
919
|
}
|
931
|
920
|
|
|
@@ -939,10 +928,10 @@ func nsUnregisterHandler(server *Server, client *Client, command string, params
|
939
|
928
|
} else {
|
940
|
929
|
account, err := server.accounts.LoadAccount(username)
|
941
|
930
|
if err == errAccountDoesNotExist {
|
942
|
|
- nsNotice(rb, client.t("Invalid account name"))
|
|
931
|
+ service.Notice(rb, client.t("Invalid account name"))
|
943
|
932
|
return
|
944
|
933
|
} else if err != nil {
|
945
|
|
- nsNotice(rb, client.t("Internal error"))
|
|
934
|
+ service.Notice(rb, client.t("Internal error"))
|
946
|
935
|
return
|
947
|
936
|
}
|
948
|
937
|
accountName = account.Name
|
|
@@ -950,34 +939,34 @@ func nsUnregisterHandler(server *Server, client *Client, command string, params
|
950
|
939
|
}
|
951
|
940
|
|
952
|
941
|
if !(accountName == client.AccountName() || client.HasRoleCapabs("accreg")) {
|
953
|
|
- nsNotice(rb, client.t("Insufficient oper privs"))
|
|
942
|
+ service.Notice(rb, client.t("Insufficient oper privs"))
|
954
|
943
|
return
|
955
|
944
|
}
|
956
|
945
|
|
957
|
946
|
expectedCode := utils.ConfirmationCode(accountName, registeredAt)
|
958
|
947
|
if expectedCode != verificationCode {
|
959
|
948
|
if erase {
|
960
|
|
- nsNotice(rb, ircfmt.Unescape(client.t("$bWarning: erasing this account will allow it to be re-registered; consider UNREGISTER instead.$b")))
|
|
949
|
+ service.Notice(rb, ircfmt.Unescape(client.t("$bWarning: erasing this account will allow it to be re-registered; consider UNREGISTER instead.$b")))
|
961
|
950
|
} else {
|
962
|
|
- nsNotice(rb, ircfmt.Unescape(client.t("$bWarning: unregistering this account will remove its stored privileges.$b")))
|
|
951
|
+ service.Notice(rb, ircfmt.Unescape(client.t("$bWarning: unregistering this account will remove its stored privileges.$b")))
|
963
|
952
|
}
|
964
|
|
- nsNotice(rb, fmt.Sprintf(client.t("To confirm, run this command: %s"), fmt.Sprintf("/NS %s %s %s", strings.ToUpper(command), accountName, expectedCode)))
|
|
953
|
+ service.Notice(rb, fmt.Sprintf(client.t("To confirm, run this command: %s"), fmt.Sprintf("/NS %s %s %s", strings.ToUpper(command), accountName, expectedCode)))
|
965
|
954
|
return
|
966
|
955
|
}
|
967
|
956
|
|
968
|
957
|
err := server.accounts.Unregister(accountName, erase)
|
969
|
958
|
if err == errAccountDoesNotExist {
|
970
|
|
- nsNotice(rb, client.t(err.Error()))
|
|
959
|
+ service.Notice(rb, client.t(err.Error()))
|
971
|
960
|
} else if err != nil {
|
972
|
|
- nsNotice(rb, client.t("Error while unregistering account"))
|
|
961
|
+ service.Notice(rb, client.t("Error while unregistering account"))
|
973
|
962
|
} else {
|
974
|
|
- nsNotice(rb, fmt.Sprintf(client.t("Successfully unregistered account %s"), accountName))
|
|
963
|
+ service.Notice(rb, fmt.Sprintf(client.t("Successfully unregistered account %s"), accountName))
|
975
|
964
|
server.logger.Info("accounts", "client", client.Nick(), "unregistered account", accountName)
|
976
|
965
|
client.server.snomasks.Send(sno.LocalAccounts, fmt.Sprintf(ircfmt.Unescape("Client $c[grey][$r%s$c[grey]] unregistered account $c[grey][$r%s$c[grey]]"), client.NickMaskString(), accountName))
|
977
|
966
|
}
|
978
|
967
|
}
|
979
|
968
|
|
980
|
|
-func nsVerifyHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
|
969
|
+func nsVerifyHandler(service *ircService, server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
981
|
970
|
username, code := params[0], params[1]
|
982
|
971
|
err := server.accounts.Verify(client, username, code)
|
983
|
972
|
|
|
@@ -992,16 +981,16 @@ func nsVerifyHandler(server *Server, client *Client, command string, params []st
|
992
|
981
|
}
|
993
|
982
|
|
994
|
983
|
if errorMessage != "" {
|
995
|
|
- nsNotice(rb, client.t(errorMessage))
|
|
984
|
+ service.Notice(rb, client.t(errorMessage))
|
996
|
985
|
return
|
997
|
986
|
}
|
998
|
987
|
|
999
|
|
- if fixupNickEqualsAccount(client, rb, server.Config()) {
|
1000
|
|
- sendSuccessfulRegResponse(client, rb, true)
|
|
988
|
+ if fixupNickEqualsAccount(client, rb, server.Config(), service.prefix) {
|
|
989
|
+ sendSuccessfulRegResponse(service, client, rb)
|
1001
|
990
|
}
|
1002
|
991
|
}
|
1003
|
992
|
|
1004
|
|
-func nsPasswdHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
|
993
|
+func nsPasswdHandler(service *ircService, server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
1005
|
994
|
var target string
|
1006
|
995
|
var newPassword string
|
1007
|
996
|
var errorMessage string
|
|
@@ -1025,7 +1014,7 @@ func nsPasswdHandler(server *Server, client *Client, command string, params []st
|
1025
|
1014
|
} else if params[1] != params[2] {
|
1026
|
1015
|
errorMessage = `Passwords do not match`
|
1027
|
1016
|
} else {
|
1028
|
|
- if !nsLoginThrottleCheck(client, rb) {
|
|
1017
|
+ if !nsLoginThrottleCheck(service, client, rb) {
|
1029
|
1018
|
return
|
1030
|
1019
|
}
|
1031
|
1020
|
accountData, err := server.accounts.LoadAccount(target)
|
|
@@ -1048,37 +1037,37 @@ func nsPasswdHandler(server *Server, client *Client, command string, params []st
|
1048
|
1037
|
}
|
1049
|
1038
|
|
1050
|
1039
|
if errorMessage != "" {
|
1051
|
|
- nsNotice(rb, client.t(errorMessage))
|
|
1040
|
+ service.Notice(rb, client.t(errorMessage))
|
1052
|
1041
|
return
|
1053
|
1042
|
}
|
1054
|
1043
|
|
1055
|
1044
|
err := server.accounts.setPassword(target, newPassword, hasPrivs)
|
1056
|
1045
|
switch err {
|
1057
|
1046
|
case nil:
|
1058
|
|
- nsNotice(rb, client.t("Password changed"))
|
|
1047
|
+ service.Notice(rb, client.t("Password changed"))
|
1059
|
1048
|
case errEmptyCredentials:
|
1060
|
|
- nsNotice(rb, client.t("You can't delete your password unless you add a certificate fingerprint"))
|
|
1049
|
+ service.Notice(rb, client.t("You can't delete your password unless you add a certificate fingerprint"))
|
1061
|
1050
|
case errCredsExternallyManaged:
|
1062
|
|
- nsNotice(rb, client.t("Your account credentials are managed externally and cannot be changed here"))
|
|
1051
|
+ service.Notice(rb, client.t("Your account credentials are managed externally and cannot be changed here"))
|
1063
|
1052
|
case errCASFailed:
|
1064
|
|
- nsNotice(rb, client.t("Try again later"))
|
|
1053
|
+ service.Notice(rb, client.t("Try again later"))
|
1065
|
1054
|
default:
|
1066
|
1055
|
server.logger.Error("internal", "could not upgrade user password:", err.Error())
|
1067
|
|
- nsNotice(rb, client.t("Password could not be changed due to server error"))
|
|
1056
|
+ service.Notice(rb, client.t("Password could not be changed due to server error"))
|
1068
|
1057
|
}
|
1069
|
1058
|
}
|
1070
|
1059
|
|
1071
|
|
-func nsEnforceHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
|
1060
|
+func nsEnforceHandler(service *ircService, server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
1072
|
1061
|
newParams := []string{"enforce"}
|
1073
|
1062
|
if len(params) == 0 {
|
1074
|
|
- nsGetHandler(server, client, "get", newParams, rb)
|
|
1063
|
+ nsGetHandler(service, server, client, "get", newParams, rb)
|
1075
|
1064
|
} else {
|
1076
|
1065
|
newParams = append(newParams, params[0])
|
1077
|
|
- nsSetHandler(server, client, "set", newParams, rb)
|
|
1066
|
+ nsSetHandler(service, server, client, "set", newParams, rb)
|
1078
|
1067
|
}
|
1079
|
1068
|
}
|
1080
|
1069
|
|
1081
|
|
-func nsClientsHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
|
1070
|
+func nsClientsHandler(service *ircService, server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
1082
|
1071
|
var verb string
|
1083
|
1072
|
|
1084
|
1073
|
if command == "sessions" {
|
|
@@ -1091,56 +1080,56 @@ func nsClientsHandler(server *Server, client *Client, command string, params []s
|
1091
|
1080
|
|
1092
|
1081
|
switch verb {
|
1093
|
1082
|
case "list":
|
1094
|
|
- nsClientsListHandler(server, client, params, rb)
|
|
1083
|
+ nsClientsListHandler(service, server, client, params, rb)
|
1095
|
1084
|
case "logout":
|
1096
|
|
- nsClientsLogoutHandler(server, client, params, rb)
|
|
1085
|
+ nsClientsLogoutHandler(service, server, client, params, rb)
|
1097
|
1086
|
default:
|
1098
|
|
- nsNotice(rb, client.t("Invalid parameters"))
|
|
1087
|
+ service.Notice(rb, client.t("Invalid parameters"))
|
1099
|
1088
|
}
|
1100
|
1089
|
}
|
1101
|
1090
|
|
1102
|
|
-func nsClientsListHandler(server *Server, client *Client, params []string, rb *ResponseBuffer) {
|
|
1091
|
+func nsClientsListHandler(service *ircService, server *Server, client *Client, params []string, rb *ResponseBuffer) {
|
1103
|
1092
|
target := client
|
1104
|
1093
|
hasPrivs := client.HasRoleCapabs("local_ban")
|
1105
|
1094
|
if 0 < len(params) {
|
1106
|
1095
|
target = server.clients.Get(params[0])
|
1107
|
1096
|
if target == nil {
|
1108
|
|
- nsNotice(rb, client.t("No such nick"))
|
|
1097
|
+ service.Notice(rb, client.t("No such nick"))
|
1109
|
1098
|
return
|
1110
|
1099
|
}
|
1111
|
1100
|
if target != client && !hasPrivs {
|
1112
|
|
- nsNotice(rb, client.t("Command restricted"))
|
|
1101
|
+ service.Notice(rb, client.t("Command restricted"))
|
1113
|
1102
|
return
|
1114
|
1103
|
}
|
1115
|
1104
|
}
|
1116
|
1105
|
|
1117
|
1106
|
sessionData, currentIndex := target.AllSessionData(rb.session, hasPrivs)
|
1118
|
|
- nsNotice(rb, fmt.Sprintf(client.t("Nickname %[1]s has %[2]d attached clients(s)"), target.Nick(), len(sessionData)))
|
|
1107
|
+ service.Notice(rb, fmt.Sprintf(client.t("Nickname %[1]s has %[2]d attached clients(s)"), target.Nick(), len(sessionData)))
|
1119
|
1108
|
for i, session := range sessionData {
|
1120
|
1109
|
if currentIndex == i {
|
1121
|
|
- nsNotice(rb, fmt.Sprintf(client.t("Client %d (currently attached client):"), session.sessionID))
|
|
1110
|
+ service.Notice(rb, fmt.Sprintf(client.t("Client %d (currently attached client):"), session.sessionID))
|
1122
|
1111
|
} else {
|
1123
|
|
- nsNotice(rb, fmt.Sprintf(client.t("Client %d:"), session.sessionID))
|
|
1112
|
+ service.Notice(rb, fmt.Sprintf(client.t("Client %d:"), session.sessionID))
|
1124
|
1113
|
}
|
1125
|
1114
|
if session.deviceID != "" {
|
1126
|
|
- nsNotice(rb, fmt.Sprintf(client.t("Device ID: %s"), session.deviceID))
|
|
1115
|
+ service.Notice(rb, fmt.Sprintf(client.t("Device ID: %s"), session.deviceID))
|
1127
|
1116
|
}
|
1128
|
|
- nsNotice(rb, fmt.Sprintf(client.t("IP address: %s"), session.ip.String()))
|
1129
|
|
- nsNotice(rb, fmt.Sprintf(client.t("Hostname: %s"), session.hostname))
|
|
1117
|
+ service.Notice(rb, fmt.Sprintf(client.t("IP address: %s"), session.ip.String()))
|
|
1118
|
+ service.Notice(rb, fmt.Sprintf(client.t("Hostname: %s"), session.hostname))
|
1130
|
1119
|
if hasPrivs {
|
1131
|
|
- nsNotice(rb, fmt.Sprintf(client.t("Connection: %s"), session.connInfo))
|
|
1120
|
+ service.Notice(rb, fmt.Sprintf(client.t("Connection: %s"), session.connInfo))
|
1132
|
1121
|
}
|
1133
|
|
- nsNotice(rb, fmt.Sprintf(client.t("Created at: %s"), session.ctime.Format(time.RFC1123)))
|
1134
|
|
- nsNotice(rb, fmt.Sprintf(client.t("Last active: %s"), session.atime.Format(time.RFC1123)))
|
|
1122
|
+ service.Notice(rb, fmt.Sprintf(client.t("Created at: %s"), session.ctime.Format(time.RFC1123)))
|
|
1123
|
+ service.Notice(rb, fmt.Sprintf(client.t("Last active: %s"), session.atime.Format(time.RFC1123)))
|
1135
|
1124
|
if session.certfp != "" {
|
1136
|
|
- nsNotice(rb, fmt.Sprintf(client.t("Certfp: %s"), session.certfp))
|
|
1125
|
+ service.Notice(rb, fmt.Sprintf(client.t("Certfp: %s"), session.certfp))
|
1137
|
1126
|
}
|
1138
|
1127
|
}
|
1139
|
1128
|
}
|
1140
|
1129
|
|
1141
|
|
-func nsClientsLogoutHandler(server *Server, client *Client, params []string, rb *ResponseBuffer) {
|
|
1130
|
+func nsClientsLogoutHandler(service *ircService, server *Server, client *Client, params []string, rb *ResponseBuffer) {
|
1142
|
1131
|
if len(params) < 1 {
|
1143
|
|
- nsNotice(rb, client.t("Missing client ID to logout (or \"all\")"))
|
|
1132
|
+ service.Notice(rb, client.t("Missing client ID to logout (or \"all\")"))
|
1144
|
1133
|
return
|
1145
|
1134
|
}
|
1146
|
1135
|
|
|
@@ -1149,14 +1138,14 @@ func nsClientsLogoutHandler(server *Server, client *Client, params []string, rb
|
1149
|
1138
|
// CLIENTS LOGOUT [nickname] [client ID]
|
1150
|
1139
|
target = server.clients.Get(params[0])
|
1151
|
1140
|
if target == nil {
|
1152
|
|
- nsNotice(rb, client.t("No such nick"))
|
|
1141
|
+ service.Notice(rb, client.t("No such nick"))
|
1153
|
1142
|
return
|
1154
|
1143
|
}
|
1155
|
1144
|
// User must have "local_kill" privileges to logout other user sessions.
|
1156
|
1145
|
if target != client {
|
1157
|
1146
|
oper := client.Oper()
|
1158
|
1147
|
if oper == nil || !oper.Class.Capabilities.Has("local_kill") {
|
1159
|
|
- nsNotice(rb, client.t("Insufficient oper privs"))
|
|
1148
|
+ service.Notice(rb, client.t("Insufficient oper privs"))
|
1160
|
1149
|
return
|
1161
|
1150
|
}
|
1162
|
1151
|
}
|
|
@@ -1167,7 +1156,7 @@ func nsClientsLogoutHandler(server *Server, client *Client, params []string, rb
|
1167
|
1156
|
if strings.ToLower(params[0]) != "all" {
|
1168
|
1157
|
sessionID, err := strconv.ParseInt(params[0], 10, 64)
|
1169
|
1158
|
if err != nil {
|
1170
|
|
- nsNotice(rb, client.t("Client ID to logout should be an integer (or \"all\")"))
|
|
1159
|
+ service.Notice(rb, client.t("Client ID to logout should be an integer (or \"all\")"))
|
1171
|
1160
|
return
|
1172
|
1161
|
}
|
1173
|
1162
|
// Find the client ID that the user requested to logout.
|
|
@@ -1178,7 +1167,7 @@ func nsClientsLogoutHandler(server *Server, client *Client, params []string, rb
|
1178
|
1167
|
}
|
1179
|
1168
|
}
|
1180
|
1169
|
if sessionToDestroy == nil {
|
1181
|
|
- nsNotice(rb, client.t("Specified client ID does not exist"))
|
|
1170
|
+ service.Notice(rb, client.t("Specified client ID does not exist"))
|
1182
|
1171
|
return
|
1183
|
1172
|
}
|
1184
|
1173
|
}
|
|
@@ -1186,14 +1175,14 @@ func nsClientsLogoutHandler(server *Server, client *Client, params []string, rb
|
1186
|
1175
|
target.destroy(sessionToDestroy)
|
1187
|
1176
|
if (sessionToDestroy != nil && rb.session != sessionToDestroy) || client != target {
|
1188
|
1177
|
if sessionToDestroy != nil {
|
1189
|
|
- nsNotice(rb, client.t("Successfully logged out session"))
|
|
1178
|
+ service.Notice(rb, client.t("Successfully logged out session"))
|
1190
|
1179
|
} else {
|
1191
|
|
- nsNotice(rb, client.t("Successfully logged out all sessions"))
|
|
1180
|
+ service.Notice(rb, client.t("Successfully logged out all sessions"))
|
1192
|
1181
|
}
|
1193
|
1182
|
}
|
1194
|
1183
|
}
|
1195
|
1184
|
|
1196
|
|
-func nsCertHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
|
1185
|
+func nsCertHandler(service *ircService, server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
1197
|
1186
|
verb := strings.ToLower(params[0])
|
1198
|
1187
|
params = params[1:]
|
1199
|
1188
|
var target, certfp string
|
|
@@ -1211,22 +1200,22 @@ func nsCertHandler(server *Server, client *Client, command string, params []stri
|
1211
|
1200
|
} else if len(params) == 0 && verb == "add" && rb.session.certfp != "" {
|
1212
|
1201
|
certfp = rb.session.certfp // #1059
|
1213
|
1202
|
} else {
|
1214
|
|
- nsNotice(rb, client.t("Invalid parameters"))
|
|
1203
|
+ service.Notice(rb, client.t("Invalid parameters"))
|
1215
|
1204
|
return
|
1216
|
1205
|
}
|
1217
|
1206
|
default:
|
1218
|
|
- nsNotice(rb, client.t("Invalid parameters"))
|
|
1207
|
+ service.Notice(rb, client.t("Invalid parameters"))
|
1219
|
1208
|
return
|
1220
|
1209
|
}
|
1221
|
1210
|
|
1222
|
1211
|
hasPrivs := client.HasRoleCapabs("accreg")
|
1223
|
1212
|
if target != "" && !hasPrivs {
|
1224
|
|
- nsNotice(rb, client.t("Insufficient privileges"))
|
|
1213
|
+ service.Notice(rb, client.t("Insufficient privileges"))
|
1225
|
1214
|
return
|
1226
|
1215
|
} else if target == "" {
|
1227
|
1216
|
target = client.Account()
|
1228
|
1217
|
if target == "" {
|
1229
|
|
- nsNotice(rb, client.t("You're not logged into an account"))
|
|
1218
|
+ service.Notice(rb, client.t("You're not logged into an account"))
|
1230
|
1219
|
return
|
1231
|
1220
|
}
|
1232
|
1221
|
}
|
|
@@ -1236,16 +1225,16 @@ func nsCertHandler(server *Server, client *Client, command string, params []stri
|
1236
|
1225
|
case "list":
|
1237
|
1226
|
accountData, err := server.accounts.LoadAccount(target)
|
1238
|
1227
|
if err == errAccountDoesNotExist {
|
1239
|
|
- nsNotice(rb, client.t("Account does not exist"))
|
|
1228
|
+ service.Notice(rb, client.t("Account does not exist"))
|
1240
|
1229
|
return
|
1241
|
1230
|
} else if err != nil {
|
1242
|
|
- nsNotice(rb, client.t("An error occurred"))
|
|
1231
|
+ service.Notice(rb, client.t("An error occurred"))
|
1243
|
1232
|
return
|
1244
|
1233
|
}
|
1245
|
1234
|
certfps := accountData.Credentials.Certfps
|
1246
|
|
- nsNotice(rb, fmt.Sprintf(client.t("There are %[1]d certificate fingerprint(s) authorized for account %[2]s."), len(certfps), accountData.Name))
|
|
1235
|
+ service.Notice(rb, fmt.Sprintf(client.t("There are %[1]d certificate fingerprint(s) authorized for account %[2]s."), len(certfps), accountData.Name))
|
1247
|
1236
|
for i, certfp := range certfps {
|
1248
|
|
- nsNotice(rb, fmt.Sprintf("%d: %s", i+1, certfp))
|
|
1237
|
+ service.Notice(rb, fmt.Sprintf("%d: %s", i+1, certfp))
|
1249
|
1238
|
}
|
1250
|
1239
|
return
|
1251
|
1240
|
case "add":
|
|
@@ -1257,54 +1246,54 @@ func nsCertHandler(server *Server, client *Client, command string, params []stri
|
1257
|
1246
|
switch err {
|
1258
|
1247
|
case nil:
|
1259
|
1248
|
if verb == "add" {
|
1260
|
|
- nsNotice(rb, client.t("Certificate fingerprint successfully added"))
|
|
1249
|
+ service.Notice(rb, client.t("Certificate fingerprint successfully added"))
|
1261
|
1250
|
} else {
|
1262
|
|
- nsNotice(rb, client.t("Certificate fingerprint successfully removed"))
|
|
1251
|
+ service.Notice(rb, client.t("Certificate fingerprint successfully removed"))
|
1263
|
1252
|
}
|
1264
|
1253
|
case errNoop:
|
1265
|
1254
|
if verb == "add" {
|
1266
|
|
- nsNotice(rb, client.t("That certificate fingerprint was already authorized"))
|
|
1255
|
+ service.Notice(rb, client.t("That certificate fingerprint was already authorized"))
|
1267
|
1256
|
} else {
|
1268
|
|
- nsNotice(rb, client.t("Certificate fingerprint not found"))
|
|
1257
|
+ service.Notice(rb, client.t("Certificate fingerprint not found"))
|
1269
|
1258
|
}
|
1270
|
1259
|
case errAccountDoesNotExist:
|
1271
|
|
- nsNotice(rb, client.t("Account does not exist"))
|
|
1260
|
+ service.Notice(rb, client.t("Account does not exist"))
|
1272
|
1261
|
case errLimitExceeded:
|
1273
|
|
- nsNotice(rb, client.t("You already have too many certificate fingerprints"))
|
|
1262
|
+ service.Notice(rb, client.t("You already have too many certificate fingerprints"))
|
1274
|
1263
|
case utils.ErrInvalidCertfp:
|
1275
|
|
- nsNotice(rb, client.t("Invalid certificate fingerprint"))
|
|
1264
|
+ service.Notice(rb, client.t("Invalid certificate fingerprint"))
|
1276
|
1265
|
case errCertfpAlreadyExists:
|
1277
|
|
- nsNotice(rb, client.t("That certificate fingerprint is already associated with another account"))
|
|
1266
|
+ service.Notice(rb, client.t("That certificate fingerprint is already associated with another account"))
|
1278
|
1267
|
case errEmptyCredentials:
|
1279
|
|
- nsNotice(rb, client.t("You can't remove all your certificate fingerprints unless you add a password"))
|
|
1268
|
+ service.Notice(rb, client.t("You can't remove all your certificate fingerprints unless you add a password"))
|
1280
|
1269
|
case errCredsExternallyManaged:
|
1281
|
|
- nsNotice(rb, client.t("Your account credentials are managed externally and cannot be changed here"))
|
|
1270
|
+ service.Notice(rb, client.t("Your account credentials are managed externally and cannot be changed here"))
|
1282
|
1271
|
case errCASFailed:
|
1283
|
|
- nsNotice(rb, client.t("Try again later"))
|
|
1272
|
+ service.Notice(rb, client.t("Try again later"))
|
1284
|
1273
|
default:
|
1285
|
1274
|
server.logger.Error("internal", "could not modify certificates:", err.Error())
|
1286
|
|
- nsNotice(rb, client.t("An error occurred"))
|
|
1275
|
+ service.Notice(rb, client.t("An error occurred"))
|
1287
|
1276
|
}
|
1288
|
1277
|
}
|
1289
|
1278
|
|
1290
|
|
-func nsSuspendHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
|
1279
|
+func nsSuspendHandler(service *ircService, server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
1291
|
1280
|
subCmd := strings.ToLower(params[0])
|
1292
|
1281
|
params = params[1:]
|
1293
|
1282
|
switch subCmd {
|
1294
|
1283
|
case "add":
|
1295
|
|
- nsSuspendAddHandler(server, client, command, params, rb)
|
|
1284
|
+ nsSuspendAddHandler(service, server, client, command, params, rb)
|
1296
|
1285
|
case "del", "delete", "remove":
|
1297
|
|
- nsSuspendRemoveHandler(server, client, command, params, rb)
|
|
1286
|
+ nsSuspendRemoveHandler(service, server, client, command, params, rb)
|
1298
|
1287
|
case "list":
|
1299
|
|
- nsSuspendListHandler(server, client, command, params, rb)
|
|
1288
|
+ nsSuspendListHandler(service, server, client, command, params, rb)
|
1300
|
1289
|
default:
|
1301
|
|
- nsNotice(rb, client.t("Invalid parameters"))
|
|
1290
|
+ service.Notice(rb, client.t("Invalid parameters"))
|
1302
|
1291
|
}
|
1303
|
1292
|
}
|
1304
|
1293
|
|
1305
|
|
-func nsSuspendAddHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
|
1294
|
+func nsSuspendAddHandler(service *ircService, server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
1306
|
1295
|
if len(params) == 0 {
|
1307
|
|
- nsNotice(rb, client.t("Invalid parameters"))
|
|
1296
|
+ service.Notice(rb, client.t("Invalid parameters"))
|
1308
|
1297
|
return
|
1309
|
1298
|
}
|
1310
|
1299
|
|
|
@@ -1316,7 +1305,7 @@ func nsSuspendAddHandler(server *Server, client *Client, command string, params
|
1316
|
1305
|
var err error
|
1317
|
1306
|
cDuration, err := custime.ParseDuration(params[1])
|
1318
|
1307
|
if err != nil {
|
1319
|
|
- nsNotice(rb, client.t("Invalid time duration for NS SUSPEND"))
|
|
1308
|
+ service.Notice(rb, client.t("Invalid time duration for NS SUSPEND"))
|
1320
|
1309
|
return
|
1321
|
1310
|
}
|
1322
|
1311
|
duration = time.Duration(cDuration)
|
|
@@ -1333,30 +1322,30 @@ func nsSuspendAddHandler(server *Server, client *Client, command string, params
|
1333
|
1322
|
err := server.accounts.Suspend(account, duration, name, reason)
|
1334
|
1323
|
switch err {
|
1335
|
1324
|
case nil:
|
1336
|
|
- nsNotice(rb, fmt.Sprintf(client.t("Successfully suspended account %s"), account))
|
|
1325
|
+ service.Notice(rb, fmt.Sprintf(client.t("Successfully suspended account %s"), account))
|
1337
|
1326
|
case errAccountDoesNotExist:
|
1338
|
|
- nsNotice(rb, client.t("No such account"))
|
|
1327
|
+ service.Notice(rb, client.t("No such account"))
|
1339
|
1328
|
default:
|
1340
|
|
- nsNotice(rb, client.t("An error occurred"))
|
|
1329
|
+ service.Notice(rb, client.t("An error occurred"))
|
1341
|
1330
|
}
|
1342
|
1331
|
}
|
1343
|
1332
|
|
1344
|
|
-func nsSuspendRemoveHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
|
1333
|
+func nsSuspendRemoveHandler(service *ircService, server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
1345
|
1334
|
if len(params) == 0 {
|
1346
|
|
- nsNotice(rb, client.t("Invalid parameters"))
|
|
1335
|
+ service.Notice(rb, client.t("Invalid parameters"))
|
1347
|
1336
|
return
|
1348
|
1337
|
}
|
1349
|
1338
|
|
1350
|
1339
|
err := server.accounts.Unsuspend(params[0])
|
1351
|
1340
|
switch err {
|
1352
|
1341
|
case nil:
|
1353
|
|
- nsNotice(rb, fmt.Sprintf(client.t("Successfully un-suspended account %s"), params[0]))
|
|
1342
|
+ service.Notice(rb, fmt.Sprintf(client.t("Successfully un-suspended account %s"), params[0]))
|
1354
|
1343
|
case errAccountDoesNotExist:
|
1355
|
|
- nsNotice(rb, client.t("No such account"))
|
|
1344
|
+ service.Notice(rb, client.t("No such account"))
|
1356
|
1345
|
case errNoop:
|
1357
|
|
- nsNotice(rb, client.t("Account was not suspended"))
|
|
1346
|
+ service.Notice(rb, client.t("Account was not suspended"))
|
1358
|
1347
|
default:
|
1359
|
|
- nsNotice(rb, client.t("An error occurred"))
|
|
1348
|
+ service.Notice(rb, client.t("An error occurred"))
|
1360
|
1349
|
}
|
1361
|
1350
|
}
|
1362
|
1351
|
|
|
@@ -1367,12 +1356,12 @@ func (a ByCreationTime) Len() int { return len(a) }
|
1367
|
1356
|
func (a ByCreationTime) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
1368
|
1357
|
func (a ByCreationTime) Less(i, j int) bool { return a[i].TimeCreated.After(a[j].TimeCreated) }
|
1369
|
1358
|
|
1370
|
|
-func nsSuspendListHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
|
1359
|
+func nsSuspendListHandler(service *ircService, server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
1371
|
1360
|
suspensions := server.accounts.ListSuspended()
|
1372
|
1361
|
sort.Sort(ByCreationTime(suspensions))
|
1373
|
|
- nsNotice(rb, fmt.Sprintf(client.t("There are %d active suspensions."), len(suspensions)))
|
|
1362
|
+ service.Notice(rb, fmt.Sprintf(client.t("There are %d active suspensions."), len(suspensions)))
|
1374
|
1363
|
for _, suspension := range suspensions {
|
1375
|
|
- nsNotice(rb, suspensionToString(client, suspension))
|
|
1364
|
+ service.Notice(rb, suspensionToString(client, suspension))
|
1376
|
1365
|
}
|
1377
|
1366
|
}
|
1378
|
1367
|
|
|
@@ -1389,21 +1378,21 @@ func suspensionToString(client *Client, suspension AccountSuspension) (result st
|
1389
|
1378
|
return fmt.Sprintf(client.t("Account %[1]s suspended at %[2]s. Duration: %[3]s. %[4]s"), suspension.AccountName, ts, duration, reason)
|
1390
|
1379
|
}
|
1391
|
1380
|
|
1392
|
|
-func nsRenameHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
|
1381
|
+func nsRenameHandler(service *ircService, server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
1393
|
1382
|
oldName, newName := params[0], params[1]
|
1394
|
1383
|
err := server.accounts.Rename(oldName, newName)
|
1395
|
1384
|
|
1396
|
1385
|
if err != nil {
|
1397
|
|
- nsNotice(rb, fmt.Sprintf(client.t("Couldn't rename account: %s"), client.t(err.Error())))
|
|
1386
|
+ service.Notice(rb, fmt.Sprintf(client.t("Couldn't rename account: %s"), client.t(err.Error())))
|
1398
|
1387
|
return
|
1399
|
1388
|
}
|
1400
|
1389
|
|
1401
|
|
- nsNotice(rb, client.t("Successfully renamed account"))
|
|
1390
|
+ service.Notice(rb, client.t("Successfully renamed account"))
|
1402
|
1391
|
if server.Config().Accounts.NickReservation.ForceNickEqualsAccount {
|
1403
|
1392
|
if curClient := server.clients.Get(oldName); curClient != nil {
|
1404
|
1393
|
renameErr := performNickChange(client.server, client, curClient, nil, newName, rb)
|
1405
|
1394
|
if renameErr != nil && renameErr != errNoop {
|
1406
|
|
- nsNotice(rb, fmt.Sprintf(client.t("Warning: could not rename affected client: %v"), err))
|
|
1395
|
+ service.Notice(rb, fmt.Sprintf(client.t("Warning: could not rename affected client: %v"), err))
|
1407
|
1396
|
}
|
1408
|
1397
|
}
|
1409
|
1398
|
}
|