diff --git a/config/config.go b/config/config.go index 061eeba3..f3e27778 100644 --- a/config/config.go +++ b/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 diff --git a/config/environments/dev.yaml b/config/environments/dev.yaml index 10d7d54f..b38c6c40 100644 --- a/config/environments/dev.yaml +++ b/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) diff --git a/servercfg/serverconf.go b/servercfg/serverconf.go index ea2c8434..b611973d 100644 --- a/servercfg/serverconf.go +++ b/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...)