mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-23 04:19:25 +01:00
Review and spec updates
This commit is contained in:
parent
7bcba602ec
commit
0b644065b7
@ -13,6 +13,7 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -609,6 +610,7 @@ func LoadConfig(filename string) (config *Config, err error) {
|
|||||||
config.Accounts.Registration.EnabledCallbacks[i] = "*"
|
config.Accounts.Registration.EnabledCallbacks[i] = "*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
sort.Strings(config.Accounts.Registration.EnabledCallbacks)
|
||||||
|
|
||||||
config.Accounts.RequireSasl.exemptedNets, err = utils.ParseNetList(config.Accounts.RequireSasl.Exempted)
|
config.Accounts.RequireSasl.exemptedNets, err = utils.ParseNetList(config.Accounts.RequireSasl.Exempted)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -40,18 +40,17 @@ func accHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Respo
|
|||||||
|
|
||||||
rb.Add(nil, server.name, "ACC", "LS", "SUBCOMMANDS", "LS REGISTER VERIFY")
|
rb.Add(nil, server.name, "ACC", "LS", "SUBCOMMANDS", "LS REGISTER VERIFY")
|
||||||
|
|
||||||
var enabledCallbacks []string
|
// this list is sorted by the config loader, yay
|
||||||
for _, name := range config.Registration.EnabledCallbacks {
|
rb.Add(nil, server.name, "ACC", "LS", "CALLBACKS", strings.Join(config.Registration.EnabledCallbacks, " "))
|
||||||
enabledCallbacks = append(enabledCallbacks, name)
|
|
||||||
}
|
|
||||||
sort.Strings(enabledCallbacks)
|
|
||||||
rb.Add(nil, server.name, "ACC", "LS", "CALLBACKS", strings.Join(enabledCallbacks, " "))
|
|
||||||
|
|
||||||
rb.Add(nil, server.name, "ACC", "LS", "CREDTYPES", "passphrase certfp")
|
rb.Add(nil, server.name, "ACC", "LS", "CREDTYPES", "passphrase certfp")
|
||||||
|
|
||||||
|
flags := []string{"nospaces"}
|
||||||
if config.NickReservation.Enabled {
|
if config.NickReservation.Enabled {
|
||||||
rb.Add(nil, server.name, "ACC", "LS", "FLAGS", "regnick")
|
flags = append(flags, "regnick")
|
||||||
}
|
}
|
||||||
|
sort.Strings(flags)
|
||||||
|
rb.Add(nil, server.name, "ACC", "LS", "FLAGS", strings.Join(flags, " "))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,7 +112,7 @@ func accRegisterHandler(server *Server, client *Client, msg ircmsg.IrcMessage, r
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
account := strings.TrimSpace(msg.Params[1])
|
account := msg.Params[1]
|
||||||
|
|
||||||
// check for account name of *
|
// check for account name of *
|
||||||
if account == "*" {
|
if account == "*" {
|
||||||
@ -166,7 +165,7 @@ func accRegisterHandler(server *Server, client *Client, msg ircmsg.IrcMessage, r
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if credentialType == "certfp" && client.certfp == "" {
|
if credentialType == "certfp" && client.certfp == "" {
|
||||||
rb.Add(nil, server.name, "FAIL", "ACC", "REG_INVALID_CRED_TYPE", account, credentialType, client.t("You are not using a TLS certificate"))
|
rb.Add(nil, server.name, "FAIL", "ACC", "REG_INVALID_CREDENTIAL", account, client.t("You must connect with a TLS client certificate to use certfp"))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,8 +189,8 @@ func accRegisterHandler(server *Server, client *Client, msg ircmsg.IrcMessage, r
|
|||||||
|
|
||||||
err = server.accounts.Register(client, account, callbackNamespace, callbackValue, passphrase, certfp)
|
err = server.accounts.Register(client, account, callbackNamespace, callbackValue, passphrase, certfp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
msg := registrationErrorToMessageAndCode(err)
|
msg, code := registrationErrorToMessageAndCode(err)
|
||||||
rb.Add(nil, server.name, "FAIL", "ACC", "REG_UNSPECIFIED_ERROR", account, client.t(msg))
|
rb.Add(nil, server.name, "FAIL", "ACC", code, account, client.t(msg))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,11 +210,15 @@ func accRegisterHandler(server *Server, client *Client, msg ircmsg.IrcMessage, r
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func registrationErrorToMessageAndCode(err error) (message string) {
|
func registrationErrorToMessageAndCode(err error) (message, code string) {
|
||||||
// default responses: let's be risk-averse about displaying internal errors
|
// default responses: let's be risk-averse about displaying internal errors
|
||||||
// to the clients, especially for something as sensitive as accounts
|
// to the clients, especially for something as sensitive as accounts
|
||||||
|
code = "REG_UNSPECIFIED_ERROR"
|
||||||
message = `Could not register`
|
message = `Could not register`
|
||||||
switch err {
|
switch err {
|
||||||
|
case errAccountBadPassphrase:
|
||||||
|
code = "REG_INVALID_CREDENTIAL"
|
||||||
|
message = err.Error()
|
||||||
case errAccountAlreadyRegistered, errAccountAlreadyVerified:
|
case errAccountAlreadyRegistered, errAccountAlreadyVerified:
|
||||||
message = err.Error()
|
message = err.Error()
|
||||||
case errAccountCreation, errAccountMustHoldNick, errAccountBadPassphrase, errCertfpAlreadyExists, errFeatureDisabled:
|
case errAccountCreation, errAccountMustHoldNick, errAccountBadPassphrase, errCertfpAlreadyExists, errFeatureDisabled:
|
||||||
|
@ -97,7 +97,8 @@ For instance, this would set the kill, oper, account and xline snomasks on dan:
|
|||||||
var Help = map[string]HelpEntry{
|
var Help = map[string]HelpEntry{
|
||||||
// Commands
|
// Commands
|
||||||
"acc": {
|
"acc": {
|
||||||
text: `ACC REGISTER <accountname> [callback_namespace:]<callback> [cred_type] :<credential>
|
text: `ACC LS
|
||||||
|
ACC REGISTER <accountname> [callback_namespace:]<callback> [cred_type] :<credential>
|
||||||
ACC VERIFY <accountname> <auth_code>
|
ACC VERIFY <accountname> <auth_code>
|
||||||
|
|
||||||
Used in account registration. See the relevant specs for more info:
|
Used in account registration. See the relevant specs for more info:
|
||||||
|
@ -406,8 +406,9 @@ func nsRegisterHandler(server *Server, client *Client, command string, params []
|
|||||||
}
|
}
|
||||||
|
|
||||||
// details could not be stored and relevant numerics have been dispatched, abort
|
// details could not be stored and relevant numerics have been dispatched, abort
|
||||||
|
message, _ := registrationErrorToMessageAndCode(err)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
nsNotice(rb, client.t(registrationErrorToMessageAndCode(err)))
|
nsNotice(rb, client.t(message))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user