MCPcopy
hub / github.com/perkeep/perkeep / serverNameOfAddr

Method serverNameOfAddr

pkg/client/client.go:1359–1369  ·  view source on GitHub ↗

serverNameOfAddr returns the host part of addr, or the empty string if addr is not a valid address (see net.Dial). Additionally, if host is an IP literal, serverNameOfAddr returns the empty string.

(addr string)

Source from the content-addressed store, hash-verified

1357// is not a valid address (see net.Dial). Additionally, if host is an IP literal,
1358// serverNameOfAddr returns the empty string.
1359func (c *Client) serverNameOfAddr(addr string) string {
1360 serverName, _, err := net.SplitHostPort(addr)
1361 if err != nil {
1362 c.printf("could not get server name from address %q: %v", addr, err)
1363 return ""
1364 }
1365 if ip := net.ParseIP(serverName); ip != nil {
1366 return ""
1367 }
1368 return serverName
1369}
1370
1371// Signer returns the client's Signer, if any. The Signer signs JSON
1372// mutation claims.

Callers 2

DialTLSFuncMethod · 0.95
TestServerOfNameFunction · 0.80

Calls 1

printfMethod · 0.95

Tested by 1

TestServerOfNameFunction · 0.64