File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ package app
2121
2222import (
2323 "errors"
24+ "fmt"
2425 "net"
2526 "net/http"
2627 "os"
@@ -293,6 +294,7 @@ func startReplica(c *cli.Context) error {
293294 host , _ := os .Hostname ()
294295 addrs , _ := net .LookupIP (host )
295296 for _ , addr := range addrs {
297+ // first try: handle addr as v4 address
296298 if ipv4 := addr .To4 (); ipv4 != nil {
297299 address = ipv4 .String ()
298300 if address == "127.0.0.1" {
@@ -301,7 +303,17 @@ func startReplica(c *cli.Context) error {
301303 }
302304 address = address + ":9502"
303305 break
306+ } else if ipv6 := addr .To16 (); ipv6 != nil {
307+ // second try: handle addr as v6 address only if we know it is not v4
308+ address = ipv6 .String ()
309+ if address == "::1" {
310+ address = fmt .Sprintf ("[%s]:9502" , address )
311+ continue
312+ }
313+ address = fmt .Sprintf ("[%s]:9502" , address )
314+ break
304315 }
316+
305317 }
306318 }
307319 controlAddress , dataAddress , syncAddress , err := util .ParseAddresses (address )
You can’t perform that action at this time.
0 commit comments