multiport: validate the peer's port range, warn when a lane never comes up

- Ignore a lane advert with a zero base port or a range running past 65535,
  with a warning, instead of aiming lanes at ports that wrapped.
- Warn once when a lane that has never come up misses 3 probes in a row.
  Until now that was silent above debug, including the common case of a
  firewall that only opens the base port.
This commit is contained in:
Wade Simmons committed 2026-10-01 16:50:49 -05:00
1 parent b93c3bfed6
commit a7e407181a
5 files changed
+100 -6

No files matched your search

+7
View File
@@ -732,6 +732,13 @@ func (hm *HandshakeManager) maybeAllocLanes(hostinfo *HostInfo, result *handshak
if len(hm.f.myVpnAddrs) == 0 || len(hostinfo.vpnAddrs) == 0 {
return
}
if !validLaneAdvert(result.PeerBasePort, result.PeerPortCount) {
// Lane targets are computed in uint16, so a range like this would wrap
// onto low ports. The tunnel itself is fine; it just gets no lanes.
hostinfo.logger(hm.l).Warn("Ignoring multiport advert with an invalid port range",
"peerBasePort", result.PeerBasePort, "peerPorts", result.PeerPortCount)
return
}
hostinfo.lanes = newLaneSet(result, hm.config.laneCount, hm.f.myVpnAddrs[0], hostinfo.vpnAddrs[0])
}