MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / FindPrimaryAddr

Function FindPrimaryAddr

base/util.go:1103–1111  ·  view source on GitHub ↗

FindPrimaryAddr returns the primary outbound IP of this machine. This is the same as find_primary_addr in sgcollect_info.

()

Source from the content-addressed store, hash-verified

1101// FindPrimaryAddr returns the primary outbound IP of this machine.
1102// This is the same as find_primary_addr in sgcollect_info.
1103func FindPrimaryAddr() (net.IP, error) {
1104 conn, err := net.Dial("udp", "8.8.8.8:56")
1105 if err != nil {
1106 return nil, err
1107 }
1108
1109 localAddr := conn.LocalAddr().(*net.UDPAddr)
1110 return localAddr.IP, conn.Close()
1111}
1112
1113// ReplaceAll returns a string with all of the given chars replaced by new
1114func ReplaceAll(s, chars, new string) string {

Callers 2

SGCollectFilenameFunction · 0.92
TestFindPrimaryAddrFunction · 0.85

Calls 1

CloseMethod · 0.65

Tested by 1

TestFindPrimaryAddrFunction · 0.68