Quellcode durchsuchen

allow overriding services hostname

Fixes #1407
tags/v2.5.0-rc1
Shivaram Lingamneni vor 3 Jahren
Ursprung
Commit
3ee6fd1f6c
5 geänderte Dateien mit 41 neuen und 13 gelöschten Zeilen
  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 Datei anzeigen

335
     # oragono will write files to disk under certain circumstances, e.g.,
335
     # oragono will write files to disk under certain circumstances, e.g.,
336
     # CPU profiling or data export. by default, these files will be written
336
     # CPU profiling or data export. by default, these files will be written
337
     # to the working directory. set this to customize:
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
 # account options
344
 # account options
341
 accounts:
345
 accounts:

+ 12
- 11
irc/config.go Datei anzeigen

526
 			forceTrailing      bool
526
 			forceTrailing      bool
527
 			SendUnprefixedSasl bool `yaml:"send-unprefixed-sasl"`
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
 	Roleplay struct {
543
 	Roleplay struct {

+ 6
- 0
irc/server.go Datei anzeigen

530
 		} else if oldConfig.Server.IPCheckScript.MaxConcurrency != config.Server.IPCheckScript.MaxConcurrency ||
530
 		} else if oldConfig.Server.IPCheckScript.MaxConcurrency != config.Server.IPCheckScript.MaxConcurrency ||
531
 			oldConfig.Accounts.AuthScript.MaxConcurrency != config.Accounts.AuthScript.MaxConcurrency {
531
 			oldConfig.Accounts.AuthScript.MaxConcurrency != config.Accounts.AuthScript.MaxConcurrency {
532
 			return fmt.Errorf("Cannot change max-concurrency for scripts after launching the server, rehash aborted")
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
 		if maxAuthConc != 0 {
565
 		if maxAuthConc != 0 {
564
 			server.semaphores.AuthScript.Initialize(maxAuthConc)
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
 	if oldConfig != nil {
574
 	if oldConfig != nil {

+ 13
- 0
irc/services.go Datei anzeigen

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
 func initializeServices() {
332
 func initializeServices() {
320
 	// this modifies the global Commands map,
333
 	// this modifies the global Commands map,
321
 	// so it must be called from irc/commands.go's init()
334
 	// so it must be called from irc/commands.go's init()

+ 5
- 1
traditional.yaml Datei anzeigen

307
     # oragono will write files to disk under certain circumstances, e.g.,
307
     # oragono will write files to disk under certain circumstances, e.g.,
308
     # CPU profiling or data export. by default, these files will be written
308
     # CPU profiling or data export. by default, these files will be written
309
     # to the working directory. set this to customize:
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
 # account options
316
 # account options
313
 accounts:
317
 accounts:

Laden…
Abbrechen
Speichern