Skip to content

Commit

Permalink
Work around macOS not implementing loopback addresses correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Dec 15, 2023
1 parent b0e32d7 commit 73f5c52
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cmd/bbctl/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"hash/crc32"
"os"
"path/filepath"
"runtime"
"strings"

"github.com/AlecAivazis/survey/v2"
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 73f5c52

Please sign in to comment.