Skip to content

Commit a5ebea8

Browse files
committed
check my ips in setup
1 parent 0758aee commit a5ebea8

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

roo/kv.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ import (
6262
"os/signal"
6363
"path/filepath"
6464
"runtime"
65+
"sort"
6566
"strconv"
6667
"syscall"
6768
"time"
@@ -75,7 +76,8 @@ import (
7576
func (kvs *KvService) connect() error {
7677

7778
myIPs, _ := getMyIPs(true)
78-
rlog.Infof("Cluster: My IPs: %s\n", getIPsString(myIPs))
79+
myIPstrings := getIPsString(myIPs)
80+
rlog.Infof("Cluster: My IPs: %s\n", myIPstrings)
7981
if kvs.AppConfig.Cluster.Binding != "" {
8082
tempBinding := kvs.AppConfig.Cluster.Binding
8183
kvs.AppConfig.Cluster.Binding = ""
@@ -157,7 +159,9 @@ func (kvs *KvService) connect() error {
157159
for {
158160
olderThan = 0
159161
for _, h := range kvs.Configuration.Hosts {
160-
if h == kvs.AppConfig.Cluster.Binding {
162+
if sort.Search(len(myIPstrings), func(i int) bool { return myIPstrings[i] == h }) > 0 ||
163+
h == kvs.AppConfig.Cluster.Binding ||
164+
net.ParseIP(h).To4() == nil {
161165
continue
162166
}
163167
getNodeStatus:
@@ -195,9 +199,6 @@ func (kvs *KvService) connect() error {
195199

196200
if status.Instantiated == kvs.AppConfig.Cluster.Service.Instantiated {
197201
fmt.Println("[ERROR] Shutting down instance to avoid contention.") //Will auto restart in swarm
198-
if h == "::1" || h == "127.0.0.1" {
199-
continue
200-
}
201202
os.Exit(1)
202203
}
203204
if status.Instantiated > kvs.AppConfig.Cluster.Service.Instantiated {

0 commit comments

Comments
 (0)