From abb832d1599881920b6e9b7ca48284f3016c5d58 Mon Sep 17 00:00:00 2001 From: Leo Antunes Date: Wed, 27 Mar 2019 00:47:23 +0100 Subject: [PATCH] be more explicit about --bind-addr --- README.md | 2 +- config.go | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 089ac2f..e79d7d3 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ All options can be passed either as command-line flags or environment variables: |---|---|---|---| | --cluster-key | WESHER_CLUSTER_KEY | shared key for cluster membership; must be 32 bytes base64 encoded; will be generated if not provided | | | --join | WESHER_JOIN | comma separated list of hostnames or IP addresses to existing cluster members; if not provided, will attempt resuming any known state or otherwise wait for further members | | -| --bind-addr | WESHER_BIND_ADDR | IP address to bind to for cluster membership | `0.0.0.0` | +| --bind-addr | WESHER_BIND_ADDR | IP address to bind to for cluster membership | automatic | | --cluster-port | WESHER_CLUSTER_PORT | port used for membership gossip traffic (both TCP and UDP); must be the same across cluster | `7946` | | --wireguard-port | WESHER_WIREGUARD_PORT | port used for wireguard traffic (UDP); must be the same across cluster | `51820` | | --overlay-net | WESHER_OVERLAY_NET | the network in which to allocate addresses for the overlay mesh network (CIDR format); smaller networks increase the chance of IP collision | `10.0.0.0/8` | diff --git a/config.go b/config.go index 6a2966d..18e4418 100644 --- a/config.go +++ b/config.go @@ -14,7 +14,7 @@ const clusterKeyLen = 32 type config struct { ClusterKey []byte `id:"cluster-key" desc:"shared key for cluster membership; must be 32 bytes base64 encoded; will be generated if not provided"` Join []string `desc:"comma separated list of hostnames or IP addresses to existing cluster members; if not provided, will attempt resuming any known state or otherwise wait for further members."` - BindAddr string `id:"bind-addr" desc:"IP address to bind to for cluster membership" default:"0.0.0.0"` + BindAddr string `id:"bind-addr" desc:"IP address to bind to for cluster membership"` ClusterPort int `id:"cluster-port" desc:"port used for membership gossip traffic (both TCP and UDP); must be the same across cluster" default:"7946"` WireguardPort int `id:"wireguard-port" desc:"port used for wireguard traffic (UDP); must be the same across cluster" default:"51820"` OverlayNet *network `id:"overlay-net" desc:"the network in which to allocate addresses for the overlay mesh network (CIDR format); smaller networks increase the chance of IP collision" default:"10.0.0.0/8"` @@ -44,14 +44,14 @@ func loadConfig() (*config, error) { } // FIXME: this is a work around for memberlist refusing to listen on public IPs - if config.BindAddr == "0.0.0.0" { - forceBindAddr, err := sockaddr.GetPublicIP() + if config.BindAddr == "" { + detectedBindAddr, err := sockaddr.GetPublicIP() if err != nil { return nil, err } // if we cannot find a public IP, let memberlist do its thing - if forceBindAddr != "" { - config.BindAddr = forceBindAddr + if detectedBindAddr != "" { + config.BindAddr = detectedBindAddr } }