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)
| 1357 | // is not a valid address (see net.Dial). Additionally, if host is an IP literal, |
| 1358 | // serverNameOfAddr returns the empty string. |
| 1359 | func (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. |