Skip to content

Commit 012f023

Browse files
chore: add missing netcheck report fields to netinfo (#56)
1 parent 1ac63d3 commit 012f023

File tree

4 files changed

+100
-3
lines changed

4 files changed

+100
-3
lines changed

tailcfg/tailcfg.go

+42-2
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,38 @@ type NetInfo struct {
733733
// This should only be updated rarely, or when there's a
734734
// material change, as any change here also gets uploaded to
735735
// the control plane.
736-
DERPLatency map[string]float64 `json:",omitempty"`
736+
// Deprecated; use DERPLatencyV4 and DERPLatencyV6 instead.
737+
DERPLatency map[string]float64 `json:",omitempty"`
738+
DERPLatencyV4 map[int]float64 `json:",omitempty"`
739+
DERPLatencyV6 map[int]float64 `json:",omitempty"`
740+
741+
// a UDP STUN round trip completed
742+
UDP bool `json:",omitempty"`
743+
744+
// an IPv6 STUN round trip completed
745+
IPv6 bool `json:",omitempty"`
746+
747+
// an IPv4 STUN round trip completed
748+
IPv4 bool `json:",omitempty"`
749+
750+
// an IPv6 packet was able to be sent
751+
IPv6CanSend bool `json:",omitempty"`
752+
753+
// an IPv4 packet was able to be sent
754+
IPv4CanSend bool `json:",omitempty"`
755+
756+
// an ICMPv4 round trip completed
757+
ICMPv4 bool
758+
759+
// ip:port of global IPv4
760+
GlobalV4 string
761+
762+
// [ip]:port of global IPv6
763+
GlobalV6 string
764+
765+
// CaptivePortal is set when we think there's a captive portal that is
766+
// intercepting HTTP traffic.
767+
CaptivePortal opt.Bool
737768

738769
// Update BasicallyEqual when adding fields.
739770
}
@@ -793,7 +824,16 @@ func (ni *NetInfo) BasicallyEqual(ni2 *NetInfo) bool {
793824
ni.PMP == ni2.PMP &&
794825
ni.PCP == ni2.PCP &&
795826
ni.PreferredDERP == ni2.PreferredDERP &&
796-
ni.LinkType == ni2.LinkType
827+
ni.LinkType == ni2.LinkType &&
828+
ni.UDP == ni2.UDP &&
829+
ni.IPv6 == ni2.IPv6 &&
830+
ni.IPv4 == ni2.IPv4 &&
831+
ni.IPv6CanSend == ni2.IPv6CanSend &&
832+
ni.IPv4CanSend == ni2.IPv4CanSend &&
833+
ni.ICMPv4 == ni2.ICMPv4 &&
834+
ni.GlobalV4 == ni2.GlobalV4 &&
835+
ni.GlobalV6 == ni2.GlobalV6 &&
836+
ni.CaptivePortal == ni2.CaptivePortal
797837
}
798838

799839
// Equal reports whether h and h2 are equal.

tailcfg/tailcfg_clone.go

+23
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tailcfg/tailcfg_view.go

+25-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

wgengine/magicsock/magicsock.go

+10
Original file line numberDiff line numberDiff line change
@@ -674,11 +674,20 @@ func (c *Conn) updateNetInfo(ctx context.Context) (*netcheck.Report, error) {
674674
PMP: report.PMP,
675675
PCP: report.PCP,
676676
HavePortMap: c.portMapper.HaveMapping(),
677+
UDP: report.UDP,
678+
IPv6: report.IPv6,
679+
IPv4: report.IPv4,
680+
IPv4CanSend: report.IPv4CanSend,
681+
ICMPv4: report.ICMPv4,
682+
GlobalV4: report.GlobalV4,
683+
GlobalV6: report.GlobalV6,
677684
}
678685
for rid, d := range report.RegionV4Latency {
686+
ni.DERPLatencyV4[rid] = d.Seconds()
679687
ni.DERPLatency[fmt.Sprintf("%d-v4", rid)] = d.Seconds()
680688
}
681689
for rid, d := range report.RegionV6Latency {
690+
ni.DERPLatencyV6[rid] = d.Seconds()
682691
ni.DERPLatency[fmt.Sprintf("%d-v6", rid)] = d.Seconds()
683692
}
684693

@@ -687,6 +696,7 @@ func (c *Conn) updateNetInfo(ctx context.Context) (*netcheck.Report, error) {
687696
ni.WorkingUDP.Set(report.UDP)
688697
ni.WorkingICMPv4.Set(report.ICMPv4)
689698
ni.PreferredDERP = report.PreferredDERP
699+
ni.CaptivePortal = report.CaptivePortal
690700

691701
if ni.PreferredDERP == 0 {
692702
// Perhaps UDP is blocked. Pick a deterministic but arbitrary

0 commit comments

Comments
 (0)