From 73f5c5250cacc5e2bfbc14490a1218cc3adc9d31 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Fri, 15 Dec 2023 19:15:56 +0200 Subject: [PATCH] Work around macOS not implementing loopback addresses correctly --- cmd/bbctl/config.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmd/bbctl/config.go b/cmd/bbctl/config.go index 63e6e3a..7e93a83 100644 --- a/cmd/bbctl/config.go +++ b/cmd/bbctl/config.go @@ -8,6 +8,7 @@ import ( "hash/crc32" "os" "path/filepath" + "runtime" "strings" "github.com/AlecAivazis/survey/v2" @@ -203,6 +204,11 @@ func doGenerateBridgeConfig(ctx *cli.Context, bridge string) (*generatedBridgeCo ipSuffix = "1" } listenAddress = "127.29.3." + ipSuffix + // macOS is weird and doesn't support loopback addresses properly, + // it only routes 127.0.0.1/32 rather than 127.0.0.0/8 + if runtime.GOOS == "darwin" { + listenAddress = "127.0.0.1" + } listenPort = uint16(30000 + (crc32.ChecksumIEEE([]byte(bridge)) % 30000)) reg.Registration.URL = fmt.Sprintf("http://%s:%d", listenAddress, listenPort) }