瀏覽代碼

allow overriding services hostname

Fixes #1407
tags/v2.5.0-rc1
Shivaram Lingamneni 3 年之前
父節點
當前提交
3ee6fd1f6c
共有 5 個檔案被更改,包括 41 行新增13 行删除
  1. 5
    1
      default.yaml
  2. 12
    11
      irc/config.go
  3. 6
    0
      irc/server.go
  4. 13
    0
      irc/services.go
  5. 5
    1
      traditional.yaml

+ 5
- 1
default.yaml 查看文件

@@ -335,7 +335,11 @@ server:
335 335
     # oragono will write files to disk under certain circumstances, e.g.,
336 336
     # CPU profiling or data export. by default, these files will be written
337 337
     # to the working directory. set this to customize:
338
-    # output-path: "/home/oragono/out"
338
+    #output-path: "/home/oragono/out"
339
+
340
+    # the hostname used by "services", e.g., NickServ, defaults to "localhost",
341
+    # e.g., `NickServ!NickServ@localhost`. uncomment this to override:
342
+    #override-services-hostname: "example.network"
339 343
 
340 344
 # account options
341 345
 accounts:

+ 12
- 11
irc/config.go 查看文件

@@ -526,17 +526,18 @@ type Config struct {
526 526
 			forceTrailing      bool
527 527
 			SendUnprefixedSasl bool `yaml:"send-unprefixed-sasl"`
528 528
 		}
529
-		isupport      isupport.List
530
-		IPLimits      connection_limits.LimiterConfig `yaml:"ip-limits"`
531
-		Cloaks        cloaks.CloakConfig              `yaml:"ip-cloaking"`
532
-		SecureNetDefs []string                        `yaml:"secure-nets"`
533
-		secureNets    []net.IPNet
534
-		supportedCaps *caps.Set
535
-		capValues     caps.Values
536
-		Casemapping   Casemapping
537
-		EnforceUtf8   bool         `yaml:"enforce-utf8"`
538
-		OutputPath    string       `yaml:"output-path"`
539
-		IPCheckScript ScriptConfig `yaml:"ip-check-script"`
529
+		isupport                 isupport.List
530
+		IPLimits                 connection_limits.LimiterConfig `yaml:"ip-limits"`
531
+		Cloaks                   cloaks.CloakConfig              `yaml:"ip-cloaking"`
532
+		SecureNetDefs            []string                        `yaml:"secure-nets"`
533
+		secureNets               []net.IPNet
534
+		supportedCaps            *caps.Set
535
+		capValues                caps.Values
536
+		Casemapping              Casemapping
537
+		EnforceUtf8              bool         `yaml:"enforce-utf8"`
538
+		OutputPath               string       `yaml:"output-path"`
539
+		IPCheckScript            ScriptConfig `yaml:"ip-check-script"`
540
+		OverrideServicesHostname string       `yaml:"override-services-hostname"`
540 541
 	}
541 542
 
542 543
 	Roleplay struct {

+ 6
- 0
irc/server.go 查看文件

@@ -530,6 +530,8 @@ func (server *Server) applyConfig(config *Config) (err error) {
530 530
 		} else if oldConfig.Server.IPCheckScript.MaxConcurrency != config.Server.IPCheckScript.MaxConcurrency ||
531 531
 			oldConfig.Accounts.AuthScript.MaxConcurrency != config.Accounts.AuthScript.MaxConcurrency {
532 532
 			return fmt.Errorf("Cannot change max-concurrency for scripts after launching the server, rehash aborted")
533
+		} else if oldConfig.Server.OverrideServicesHostname != config.Server.OverrideServicesHostname {
534
+			return fmt.Errorf("Cannot change override-services-hostname after launching the server, rehash aborted")
533 535
 		}
534 536
 	}
535 537
 
@@ -563,6 +565,10 @@ func (server *Server) applyConfig(config *Config) (err error) {
563 565
 		if maxAuthConc != 0 {
564 566
 			server.semaphores.AuthScript.Initialize(maxAuthConc)
565 567
 		}
568
+
569
+		if err := overrideServicePrefixes(config.Server.OverrideServicesHostname); err != nil {
570
+			return err
571
+		}
566 572
 	}
567 573
 
568 574
 	if oldConfig != nil {

+ 13
- 0
irc/services.go 查看文件

@@ -316,6 +316,19 @@ func makeServiceHelpTextGenerator(cmd string, banner string) func(*Client) strin
316 316
 	}
317 317
 }
318 318
 
319
+func overrideServicePrefixes(hostname string) error {
320
+	if hostname == "" {
321
+		return nil
322
+	}
323
+	if !utils.IsHostname(hostname) {
324
+		return fmt.Errorf("`%s` is an invalid services hostname", hostname)
325
+	}
326
+	for _, serv := range OragonoServices {
327
+		serv.prefix = fmt.Sprintf("%s!%s@%s", serv.Name, serv.Name, hostname)
328
+	}
329
+	return nil
330
+}
331
+
319 332
 func initializeServices() {
320 333
 	// this modifies the global Commands map,
321 334
 	// so it must be called from irc/commands.go's init()

+ 5
- 1
traditional.yaml 查看文件

@@ -307,7 +307,11 @@ server:
307 307
     # oragono will write files to disk under certain circumstances, e.g.,
308 308
     # CPU profiling or data export. by default, these files will be written
309 309
     # to the working directory. set this to customize:
310
-    # output-path: "/home/oragono/out"
310
+    #output-path: "/home/oragono/out"
311
+
312
+    # the hostname used by "services", e.g., NickServ, defaults to "localhost",
313
+    # e.g., `NickServ!NickServ@localhost`. uncomment this to override:
314
+    #override-services-hostname: "example.network"
311 315
 
312 316
 # account options
313 317
 accounts:

Loading…
取消
儲存