MCPcopy Create free account
hub / github.com/daodst/chat / stripIPPort

Function stripIPPort

clientapi/routing/device.go:272–286  ·  view source on GitHub ↗

stripIPPort converts strings like "[::1]:12345" to "::1"

(addr string)

Source from the content-addressed store, hash-verified

270
271// stripIPPort converts strings like "[::1]:12345" to "::1"
272func stripIPPort(addr string) string {
273 ip := net.ParseIP(addr)
274 if ip != nil {
275 return addr
276 }
277 host, _, err := net.SplitHostPort(addr)
278 if err != nil {
279 return ""
280 }
281 ip = net.ParseIP(host)
282 if ip != nil {
283 return host
284 }
285 return ""
286}

Callers 2

GetDeviceByIDFunction · 0.85
GetDevicesByLocalpartFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected