all: use strings.Cut even more
Change-Id: I943ce72c6f339589235bddbe10d07799c4e37979 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
committed by
Brad Fitzpatrick
parent
f30473211b
commit
f2041c9088
@@ -676,7 +676,7 @@ func pfx(strs ...string) (ret []netaddr.IPPrefix) {
|
||||
|
||||
func nets(nets ...string) (ret []netaddr.IPPrefix) {
|
||||
for _, s := range nets {
|
||||
if i := strings.IndexByte(s, '/'); i == -1 {
|
||||
if !strings.Contains(s, "/") {
|
||||
ip, err := netaddr.ParseIP(s)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
||||
@@ -188,8 +188,8 @@ func peerDebugName(p *tailcfg.Node) string {
|
||||
return ""
|
||||
}
|
||||
n := p.Name
|
||||
if i := strings.Index(n, "."); i != -1 {
|
||||
return n[:i]
|
||||
if base, _, ok := strings.Cut(n, "."); ok {
|
||||
return base
|
||||
}
|
||||
return p.Hostinfo.Hostname()
|
||||
}
|
||||
|
||||
@@ -905,9 +905,7 @@ func (c *Conn) Ping(peer *tailcfg.Node, res *ipnstate.PingResult, cb func(*ipnst
|
||||
if res.NodeName == "" {
|
||||
res.NodeName = peer.Hostinfo.Hostname() // else hostname
|
||||
} else {
|
||||
if i := strings.Index(res.NodeName, "."); i != -1 {
|
||||
res.NodeName = res.NodeName[:i]
|
||||
}
|
||||
res.NodeName, _, _ = strings.Cut(res.NodeName, ".")
|
||||
}
|
||||
|
||||
ep, ok := c.peerMap.endpointForNodeKey(peer.Key)
|
||||
|
||||
Reference in New Issue
Block a user