Signed-off-by: Andrew Dunham <andrew@du.nham.ca>
Change-Id: I085e259fc45e7067a5a09a9e842cf66c700f0802
This commit is contained in:
Andrew Dunham 2023-02-03 16:44:23 -05:00
parent 0e1403ec39
commit 9e61fc7721
4 changed files with 9 additions and 9 deletions

View File

@ -593,7 +593,7 @@ type NetInfo struct {
// HavePortMap is whether we have an existing portmap open // HavePortMap is whether we have an existing portmap open
// (UPnP, PMP, or PCP). // (UPnP, PMP, or PCP).
HavePortMap bool `json:",omitempty"` HavePortMap opt.Bool
// UPnP is whether UPnP appears present on the LAN. // UPnP is whether UPnP appears present on the LAN.
// Empty means not checked. // Empty means not checked.
@ -642,11 +642,11 @@ func (ni *NetInfo) String() string {
} }
func (ni *NetInfo) portMapSummary() string { func (ni *NetInfo) portMapSummary() string {
if !ni.HavePortMap && ni.UPnP == "" && ni.PMP == "" && ni.PCP == "" { if ni.HavePortMap == "" && ni.UPnP == "" && ni.PMP == "" && ni.PCP == "" {
return "?" return "?"
} }
var prefix string var prefix string
if ni.HavePortMap { if v, _ := ni.HavePortMap.Get(); v {
prefix = "active-" prefix = "active-"
} }
return prefix + conciseOptBool(ni.UPnP, "U") + conciseOptBool(ni.PMP, "M") + conciseOptBool(ni.PCP, "C") return prefix + conciseOptBool(ni.UPnP, "U") + conciseOptBool(ni.PMP, "M") + conciseOptBool(ni.PCP, "C")

View File

@ -177,7 +177,7 @@ func (src *NetInfo) Clone() *NetInfo {
OSHasIPv6 opt.Bool OSHasIPv6 opt.Bool
WorkingUDP opt.Bool WorkingUDP opt.Bool
WorkingICMPv4 opt.Bool WorkingICMPv4 opt.Bool
HavePortMap bool HavePortMap opt.Bool
UPnP opt.Bool UPnP opt.Bool
PMP opt.Bool PMP opt.Bool
PCP opt.Bool PCP opt.Bool

View File

@ -380,7 +380,7 @@ func (v NetInfoView) WorkingIPv6() opt.Bool { return v.ж.WorkingIPv6
func (v NetInfoView) OSHasIPv6() opt.Bool { return v.ж.OSHasIPv6 } func (v NetInfoView) OSHasIPv6() opt.Bool { return v.ж.OSHasIPv6 }
func (v NetInfoView) WorkingUDP() opt.Bool { return v.ж.WorkingUDP } func (v NetInfoView) WorkingUDP() opt.Bool { return v.ж.WorkingUDP }
func (v NetInfoView) WorkingICMPv4() opt.Bool { return v.ж.WorkingICMPv4 } func (v NetInfoView) WorkingICMPv4() opt.Bool { return v.ж.WorkingICMPv4 }
func (v NetInfoView) HavePortMap() bool { return v.ж.HavePortMap } func (v NetInfoView) HavePortMap() opt.Bool { return v.ж.HavePortMap }
func (v NetInfoView) UPnP() opt.Bool { return v.ж.UPnP } func (v NetInfoView) UPnP() opt.Bool { return v.ж.UPnP }
func (v NetInfoView) PMP() opt.Bool { return v.ж.PMP } func (v NetInfoView) PMP() opt.Bool { return v.ж.PMP }
func (v NetInfoView) PCP() opt.Bool { return v.ж.PCP } func (v NetInfoView) PCP() opt.Bool { return v.ж.PCP }
@ -398,7 +398,7 @@ func (v NetInfoView) String() string { return v.ж.Stri
OSHasIPv6 opt.Bool OSHasIPv6 opt.Bool
WorkingUDP opt.Bool WorkingUDP opt.Bool
WorkingICMPv4 opt.Bool WorkingICMPv4 opt.Bool
HavePortMap bool HavePortMap opt.Bool
UPnP opt.Bool UPnP opt.Bool
PMP opt.Bool PMP opt.Bool
PCP opt.Bool PCP opt.Bool

View File

@ -793,12 +793,12 @@ func (c *Conn) setNetInfoHavePortMap() {
// No NetInfo yet. Nothing to update. // No NetInfo yet. Nothing to update.
return return
} }
if c.netInfoLast.HavePortMap { if v, _ := c.netInfoLast.HavePortMap.Get(); v {
// No change. // No change.
return return
} }
ni := c.netInfoLast.Clone() ni := c.netInfoLast.Clone()
ni.HavePortMap = true ni.HavePortMap.Set(true)
c.callNetInfoCallbackLocked(ni) c.callNetInfoCallbackLocked(ni)
} }
@ -834,8 +834,8 @@ func (c *Conn) updateNetInfo(ctx context.Context) (*netcheck.Report, error) {
UPnP: report.UPnP, UPnP: report.UPnP,
PMP: report.PMP, PMP: report.PMP,
PCP: report.PCP, PCP: report.PCP,
HavePortMap: c.portMapper.HaveMapping(),
} }
ni.HavePortMap.Set(c.portMapper.HaveMapping())
for rid, d := range report.RegionV4Latency { for rid, d := range report.RegionV4Latency {
ni.DERPLatency[fmt.Sprintf("%d-v4", rid)] = d.Seconds() ni.DERPLatency[fmt.Sprintf("%d-v4", rid)] = d.Seconds()
} }