Added config file handling for public IP service.

This commit is contained in:
cameronts 2022-07-27 11:57:37 -07:00
parent a2f2b81142
commit 067d2aca2d
3 changed files with 9 additions and 1 deletions

View file

@ -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

View file

@ -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)

View file

@ -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...)