diff --git a/README.md b/README.md index 1e03172..c7d0273 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ wireguard interface stats. See the `cap_add` and `network_mode` options on the d | `SESSION_SECRET` | Used to encrypt the session cookies. Set this to a random value. | | `WGUI_USERNAME` | The username for the login page. (default `admin`) | | `WGUI_PASSWORD` | The password for the user on the login page. (default `admin`) | +| `WGUI_ENDPOINT_ADDRESS` | The default endpoint address used in global settings. (default is your public IP address) | | `WGUI_DNS` | The default DNS servers (comma-separated-list) used in the global settings. (default `1.1.1.1`) | | `WGUI_MTU` | The default MTU used in global settings. (default `1450`) | | `WGUI_PERSISTENT_KEEPALIVE` | The default persistent keepalive for WireGuard in global settings. (default `15`) | diff --git a/store/jsondb/jsondb.go b/store/jsondb/jsondb.go index 356ee0b..755145b 100644 --- a/store/jsondb/jsondb.go +++ b/store/jsondb/jsondb.go @@ -88,7 +88,7 @@ func (o *JsonDB) Init() error { } globalSetting := new(model.GlobalSetting) - globalSetting.EndpointAddress = publicInterface.IPAddress + globalSetting.EndpointAddress = util.LookupEnvOrString(util.EndpointAddressEnvVar, publicInterface.IPAddress) 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) diff --git a/util/config.go b/util/config.go index 2e3f377..f5967eb 100644 --- a/util/config.go +++ b/util/config.go @@ -34,6 +34,7 @@ const ( DefaultConfigFilePath = "/etc/wireguard/wg0.conf" UsernameEnvVar = "WGUI_USERNAME" PasswordEnvVar = "WGUI_PASSWORD" + EndpointAddressEnvVar = "WGUI_ENDPOINT_ADDRESS" DNSEnvVar = "WGUI_DNS" MTUEnvVar = "WGUI_MTU" PersistentKeepaliveEnvVar = "WGUI_PERSISTENT_KEEPALIVE"