Refine direct connection validation logic in TestPingAllByIPDirectConnections

Co-authored-by: kradalby <98431+kradalby@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-11-01 08:22:28 +00:00
parent 2ac534dd30
commit aafe727cb9

View File

@@ -164,23 +164,18 @@ func TestPingAllByIPDirectConnections(t *testing.T) {
peerStatus := status.Peer[peerKey] peerStatus := status.Peer[peerKey]
// CurAddr indicates the current address being used to communicate with this peer // CurAddr indicates the current address being used to communicate with this peer
// If CurAddr is not empty and doesn't start with the DERP region ID, it's a direct connection // Direct connections have CurAddr set to an actual IP:port
if peerStatus.CurAddr != "" { // DERP-relayed connections either have no CurAddr or it contains the DERP magic IP
// Direct connections will have an IP:port format if peerStatus.CurAddr != "" && !strings.Contains(peerStatus.CurAddr, "127.3.3.40") {
// Relayed connections typically show up differently or are empty // This is a direct connection - CurAddr contains the actual peer IP:port
if !strings.Contains(peerStatus.CurAddr, "127.3.3.40") { // DERP relay address pattern directCount++
directCount++ t.Logf("Client %s -> Peer %s: DIRECT connection via %s (relay: %s)",
t.Logf("Client %s -> Peer %s: DIRECT connection via %s", client.Hostname(), peerStatus.HostName, peerStatus.CurAddr, peerStatus.Relay)
client.Hostname(), peerStatus.HostName, peerStatus.CurAddr)
} else {
relayedCount++
t.Logf("Client %s -> Peer %s: RELAYED connection via %s",
client.Hostname(), peerStatus.HostName, peerStatus.CurAddr)
}
} else { } else {
// This is a relayed connection through DERP
relayedCount++ relayedCount++
t.Logf("Client %s -> Peer %s: No CurAddr (likely relayed via %s)", t.Logf("Client %s -> Peer %s: RELAYED connection (CurAddr: %s, relay: %s)",
client.Hostname(), peerStatus.HostName, peerStatus.Relay) client.Hostname(), peerStatus.HostName, peerStatus.CurAddr, peerStatus.Relay)
} }
} }