3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-29 07:29:31 +01:00

allow overriding services hostname

Fixes #1407
This commit is contained in:
Shivaram Lingamneni 2020-11-28 23:40:21 -05:00
parent 9214d978d0
commit 3ee6fd1f6c
5 changed files with 41 additions and 13 deletions

View File

@ -337,6 +337,10 @@ server:
# to the working directory. set this to customize: # to the working directory. set this to customize:
#output-path: "/home/oragono/out" #output-path: "/home/oragono/out"
# the hostname used by "services", e.g., NickServ, defaults to "localhost",
# e.g., `NickServ!NickServ@localhost`. uncomment this to override:
#override-services-hostname: "example.network"
# account options # account options
accounts: accounts:
# is account authentication enabled, i.e., can users log into existing accounts? # is account authentication enabled, i.e., can users log into existing accounts?

View File

@ -537,6 +537,7 @@ type Config struct {
EnforceUtf8 bool `yaml:"enforce-utf8"` EnforceUtf8 bool `yaml:"enforce-utf8"`
OutputPath string `yaml:"output-path"` OutputPath string `yaml:"output-path"`
IPCheckScript ScriptConfig `yaml:"ip-check-script"` IPCheckScript ScriptConfig `yaml:"ip-check-script"`
OverrideServicesHostname string `yaml:"override-services-hostname"`
} }
Roleplay struct { Roleplay struct {

View File

@ -530,6 +530,8 @@ func (server *Server) applyConfig(config *Config) (err error) {
} else if oldConfig.Server.IPCheckScript.MaxConcurrency != config.Server.IPCheckScript.MaxConcurrency || } else if oldConfig.Server.IPCheckScript.MaxConcurrency != config.Server.IPCheckScript.MaxConcurrency ||
oldConfig.Accounts.AuthScript.MaxConcurrency != config.Accounts.AuthScript.MaxConcurrency { oldConfig.Accounts.AuthScript.MaxConcurrency != config.Accounts.AuthScript.MaxConcurrency {
return fmt.Errorf("Cannot change max-concurrency for scripts after launching the server, rehash aborted") return fmt.Errorf("Cannot change max-concurrency for scripts after launching the server, rehash aborted")
} else if oldConfig.Server.OverrideServicesHostname != config.Server.OverrideServicesHostname {
return fmt.Errorf("Cannot change override-services-hostname after launching the server, rehash aborted")
} }
} }
@ -563,6 +565,10 @@ func (server *Server) applyConfig(config *Config) (err error) {
if maxAuthConc != 0 { if maxAuthConc != 0 {
server.semaphores.AuthScript.Initialize(maxAuthConc) server.semaphores.AuthScript.Initialize(maxAuthConc)
} }
if err := overrideServicePrefixes(config.Server.OverrideServicesHostname); err != nil {
return err
}
} }
if oldConfig != nil { if oldConfig != nil {

View File

@ -316,6 +316,19 @@ func makeServiceHelpTextGenerator(cmd string, banner string) func(*Client) strin
} }
} }
func overrideServicePrefixes(hostname string) error {
if hostname == "" {
return nil
}
if !utils.IsHostname(hostname) {
return fmt.Errorf("`%s` is an invalid services hostname", hostname)
}
for _, serv := range OragonoServices {
serv.prefix = fmt.Sprintf("%s!%s@%s", serv.Name, serv.Name, hostname)
}
return nil
}
func initializeServices() { func initializeServices() {
// this modifies the global Commands map, // this modifies the global Commands map,
// so it must be called from irc/commands.go's init() // so it must be called from irc/commands.go's init()

View File

@ -309,6 +309,10 @@ server:
# to the working directory. set this to customize: # to the working directory. set this to customize:
#output-path: "/home/oragono/out" #output-path: "/home/oragono/out"
# the hostname used by "services", e.g., NickServ, defaults to "localhost",
# e.g., `NickServ!NickServ@localhost`. uncomment this to override:
#override-services-hostname: "example.network"
# account options # account options
accounts: accounts:
# is account authentication enabled, i.e., can users log into existing accounts? # is account authentication enabled, i.e., can users log into existing accounts?