leaderless gossip-based service discovery w/ consul compatibility
5

Configure Feed

Select the types of activity you want to include in your feed.

fix cascade bind regression

Jes Olson (Feb 20, 2023, 4:35 AM -0800) 60a2e199 d9e4dd86

+42 -5
-2
agent/agent.go
··· 189 189 if err != nil { 190 190 return n, fmt.Errorf("Error joining: %v\n", err) 191 191 } 192 - // TODO: when joining fails, we don't get an error here - serf & memberlist 193 - // just print to stdout and serf.Join returns without issue. 194 192 return n, err 195 193 } 196 194
+1 -1
agent/config.go
··· 6 6 ) 7 7 8 8 const DefaultBindPort int = 4443 9 - const DefaultClientPort int = 4443 9 + const DefaultClientPort int = 4444 10 10 11 11 func DefaultConfig() *Config { 12 12 hostname, err := os.Hostname()
+34
ipaddr/ipaddr.go
··· 1 + package ipaddr 2 + 3 + import ( 4 + "log" 5 + "net" 6 + "strconv" 7 + "strings" 8 + ) 9 + 10 + // resolveHost will take a single host string and convert it to a list of TCPAddrs 11 + // This will process any port in the input as well as looking up the hostname using 12 + // normal DNS resolution. 13 + func ParseIPPort(IPPort string) *net.TCPAddr { 14 + var addr net.TCPAddr 15 + ip, portStr, err := net.SplitHostPort(IPPort) 16 + if err != nil { 17 + if strings.Contains(err.Error(), "missing port in address") { 18 + ip = IPPort 19 + } else { 20 + log.Printf("error splitting ip+port '%s' into IP and port: %s\n", IPPort, err) 21 + return &addr 22 + } 23 + } else { 24 + addr.Port, err = strconv.Atoi(portStr) 25 + if err != nil { 26 + log.Printf("Parsed port '%s' is not an integer: %s\n", portStr, err) 27 + return &addr 28 + } 29 + } 30 + 31 + addr.IP = net.ParseIP(ip) 32 + 33 + return &addr 34 + }
+7 -2
main.go
··· 10 10 "time" 11 11 12 12 "git.j3s.sh/cascade/agent" 13 + "git.j3s.sh/cascade/ipaddr" 13 14 "git.j3s.sh/cascade/list" 14 15 ) 15 16 ··· 47 48 48 49 func handleAgent() { 49 50 config := getAgentConfig() 51 + fmt.Printf("%+v", config) 50 52 agent := agent.New(config) 51 53 if err := agent.Start(); err != nil { 52 54 fmt.Println(err) ··· 134 136 config := agent.DefaultConfig() 135 137 // CASCADE_BIND=192.168.0.15:12345 136 138 if os.Getenv("CASCADE_BIND") != "" { 137 - //TODO 138 - // config.BindAddr = os.Getenv("CASCADE_BIND") 139 + addr := ipaddr.ParseIPPort(os.Getenv("CASCADE_BIND")) 140 + config.BindAddr.IP = addr.IP 141 + if addr.Port != 0 { 142 + config.BindAddr.Port = addr.Port 143 + } 139 144 } 140 145 // CASCADE_JOIN=127.0.0.1,127.0.0.5 141 146 if os.Getenv("CASCADE_JOIN") != "" {