net/netcheck: flesh out some logging in error paths
Updates tailscale/corp#20654 Change-Id: Ie190f956b864985668f79b5b986438bbe07ce905
This commit is contained in:
parent
95f266f1ce
commit
8450a18aa9
|
@ -340,6 +340,18 @@ const (
|
||||||
probeHTTPS // HTTPS
|
probeHTTPS // HTTPS
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func (p probeProto) String() string {
|
||||||
|
switch p {
|
||||||
|
case probeIPv4:
|
||||||
|
return "v4"
|
||||||
|
case probeIPv6:
|
||||||
|
return "v4"
|
||||||
|
case probeHTTPS:
|
||||||
|
return "https"
|
||||||
|
}
|
||||||
|
return "?"
|
||||||
|
}
|
||||||
|
|
||||||
type probe struct {
|
type probe struct {
|
||||||
// delay is when the probe is started, relative to the time
|
// delay is when the probe is started, relative to the time
|
||||||
// that GetReport is called. One probe in each probePlan
|
// that GetReport is called. One probe in each probePlan
|
||||||
|
@ -1229,7 +1241,7 @@ func (c *Client) measureICMPLatency(ctx context.Context, reg *tailcfg.DERPRegion
|
||||||
// TODO(andrew-d): this is a bit ugly
|
// TODO(andrew-d): this is a bit ugly
|
||||||
nodeAddr := c.nodeAddr(ctx, node, probeIPv4)
|
nodeAddr := c.nodeAddr(ctx, node, probeIPv4)
|
||||||
if !nodeAddr.IsValid() {
|
if !nodeAddr.IsValid() {
|
||||||
return 0, false, fmt.Errorf("no address for node %v", node.Name)
|
return 0, false, fmt.Errorf("no address for node %v (v4-for-icmp)", node.Name)
|
||||||
}
|
}
|
||||||
addr := &net.IPAddr{
|
addr := &net.IPAddr{
|
||||||
IP: net.IP(nodeAddr.Addr().AsSlice()),
|
IP: net.IP(nodeAddr.Addr().AsSlice()),
|
||||||
|
@ -1481,7 +1493,7 @@ func (rs *reportState) runProbe(ctx context.Context, dm *tailcfg.DERPMap, probe
|
||||||
|
|
||||||
addr := c.nodeAddr(ctx, node, probe.proto)
|
addr := c.nodeAddr(ctx, node, probe.proto)
|
||||||
if !addr.IsValid() {
|
if !addr.IsValid() {
|
||||||
c.logf("netcheck.runProbe: named node %q has no address", probe.node)
|
c.logf("netcheck.runProbe: named node %q has no %v address", probe.node, probe.proto)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1607,12 +1619,15 @@ func (c *Client) nodeAddr(ctx context.Context, n *tailcfg.DERPNode, proto probeP
|
||||||
c.mu.Unlock()
|
c.mu.Unlock()
|
||||||
|
|
||||||
probeIsV4 := proto == probeIPv4
|
probeIsV4 := proto == probeIPv4
|
||||||
addrs, _ := lookupIPAddr(ctx, n.HostName)
|
addrs, err := lookupIPAddr(ctx, n.HostName)
|
||||||
for _, a := range addrs {
|
for _, a := range addrs {
|
||||||
if (a.Is4() && probeIsV4) || (a.Is6() && !probeIsV4) {
|
if (a.Is4() && probeIsV4) || (a.Is6() && !probeIsV4) {
|
||||||
return netip.AddrPortFrom(a, uint16(port))
|
return netip.AddrPortFrom(a, uint16(port))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if err != nil {
|
||||||
|
c.logf("netcheck: DNS lookup error for %q (node %q region %v): %v", n.HostName, n.Name, n.RegionID, err)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -624,18 +624,6 @@ func (p probe) String() string {
|
||||||
return fmt.Sprintf("%s-%s%s%s", p.node, p.proto, delay, wait)
|
return fmt.Sprintf("%s-%s%s%s", p.node, p.proto, delay, wait)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p probeProto) String() string {
|
|
||||||
switch p {
|
|
||||||
case probeIPv4:
|
|
||||||
return "v4"
|
|
||||||
case probeIPv6:
|
|
||||||
return "v4"
|
|
||||||
case probeHTTPS:
|
|
||||||
return "https"
|
|
||||||
}
|
|
||||||
return "?"
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestLogConciseReport(t *testing.T) {
|
func TestLogConciseReport(t *testing.T) {
|
||||||
dm := &tailcfg.DERPMap{
|
dm := &tailcfg.DERPMap{
|
||||||
Regions: map[int]*tailcfg.DERPRegion{
|
Regions: map[int]*tailcfg.DERPRegion{
|
||||||
|
|
Loading…
Reference in New Issue