Browse Source

Merge pull request #1426 from gravitl/feature_v0.14.7_netmakeraddvarforpublicipservice

Netmaker: Added config file handling for public IP service.
dcarns 3 years ago
parent
commit
28875981b1
3 changed files with 9 additions and 1 deletions
  1. 1 0
      config/config.go
  2. 1 0
      config/environments/dev.yaml
  3. 7 1
      servercfg/serverconf.go

+ 1 - 0
config/config.go

@@ -69,6 +69,7 @@ type ServerConfig struct {
 	MQPort                string `yaml:"mqport"`
 	MQServerPort          string `yaml:"mqserverport"`
 	Server                string `yaml:"server"`
+	PublicIPService       string `yaml:"publicipservice"`
 }
 
 // SQLConfig - Generic SQL Config

+ 1 - 0
config/environments/dev.yaml

@@ -11,3 +11,4 @@ server:
   disableremoteipcheck: "" # defaults to "false" or DISABLE_REMOTE_IP_CHECK (if set)
   version: "" # version of server
   rce: "" # defaults to "off"
+  publicipservice: "" # defaults to "" or PUBLIC_IP_SERVICE (if set)

+ 7 - 1
servercfg/serverconf.go

@@ -430,7 +430,13 @@ func GetPublicIP() (string, error) {
 	iplist := []string{"https://ip.server.gravitl.com", "https://ifconfig.me", "https://api.ipify.org", "https://ipinfo.io/ip"}
 	publicIpService := os.Getenv("PUBLIC_IP_SERVICE")
 	if publicIpService != "" {
-		logger.Log(3, "User provided public IP service is", publicIpService)
+		logger.Log(3, "User (environment variable) provided public IP service is", publicIpService)
+
+		// prepend the user-specified service so it's checked first
+		iplist = append([]string{publicIpService}, iplist...)
+	} else if config.Config.Server.PublicIPService != "" {
+		publicIpService = config.Config.Server.PublicIPService
+		logger.Log(3, "User (config file) provided public IP service is", publicIpService)
 
 		// prepend the user-specified service so it's checked first
 		iplist = append([]string{publicIpService}, iplist...)