Disable automatic endpoint address detection when endpoint is supplied (#240)

This commit is contained in:
Marcus Wichelmann 2022-12-02 23:10:49 +01:00 committed by GitHub
parent 033bea6fb1
commit 9d2dd711a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -81,14 +81,18 @@ func (o *JsonDB) Init() error {
// global settings
if _, err := os.Stat(globalSettingPath); os.IsNotExist(err) {
publicInterface, err := util.GetPublicIP()
if err != nil {
return err
endpointAddress := util.LookupEnvOrString(util.EndpointAddressEnvVar, "")
if endpointAddress == "" {
// automatically find an external IP address
publicInterface, err := util.GetPublicIP()
if err != nil {
return err
}
endpointAddress = publicInterface.IPAddress
}
globalSetting := new(model.GlobalSetting)
globalSetting.EndpointAddress = util.LookupEnvOrString(util.EndpointAddressEnvVar, publicInterface.IPAddress)
globalSetting.EndpointAddress = endpointAddress
globalSetting.DNSServers = util.LookupEnvOrStrings(util.DNSEnvVar, []string{util.DefaultDNS})
globalSetting.MTU = util.LookupEnvOrInt(util.MTUEnvVar, util.DefaultMTU)
globalSetting.PersistentKeepalive = util.LookupEnvOrInt(util.PersistentKeepaliveEnvVar, util.DefaultPersistentKeepalive)