mirror of
https://github.com/netbirdio/netbird.git
synced 2026-10-12 00:19:08 +02:00
Renaming according to actual meanings
This commit is contained in:
@@ -829,7 +829,7 @@ func (conn *Conn) isConnectedOnAllWay() (status guard.ConnStatus) {
|
|||||||
relayTransportConnected: conn.workerRelay.IsTransportConnected(),
|
relayTransportConnected: conn.workerRelay.IsTransportConnected(),
|
||||||
remoteSupportsICE: conn.handshaker.RemoteICESupported(),
|
remoteSupportsICE: conn.handshaker.RemoteICESupported(),
|
||||||
iceWorkerCreated: iceWorkerCreated,
|
iceWorkerCreated: iceWorkerCreated,
|
||||||
iceStatusConnecting: conn.statusICE.Get() != worker.StatusDisconnected,
|
iceStatusConnected: conn.statusICE.Get() == worker.StatusConnected,
|
||||||
iceInProgress: iceInProgress,
|
iceInProgress: iceInProgress,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -1042,20 +1042,19 @@ func evalConnStatus(in connStatusInputs) guard.ConnStatus {
|
|||||||
return boolToConnStatus(relayUsedAndUp)
|
return boolToConnStatus(relayUsedAndUp)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ICE counts as "up" when the status is anything other than Disconnected, OR
|
// ICE counts as "running" when either connected or attempting to connect.
|
||||||
// when a negotiation is currently in progress (so we don't spam offers while one is in flight).
|
iceRunning := in.iceStatusConnected || in.iceInProgress
|
||||||
iceUp := in.iceStatusConnecting || in.iceInProgress
|
|
||||||
|
|
||||||
// Relay side is acceptable if the peer doesn't rely on relay, or relay is connected.
|
// Relay side is acceptable if the peer doesn't rely on relay, or relay is connected.
|
||||||
relayOK := !in.peerUsesRelay || in.relayConnected
|
relayOK := !in.peerUsesRelay || in.relayConnected
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case iceUp && relayOK:
|
case iceRunning && relayOK:
|
||||||
return guard.ConnStatusConnected
|
return guard.ConnStatusConnected
|
||||||
case relayUsedAndUp:
|
case relayUsedAndUp:
|
||||||
// Relay is up but ICE is down — partially connected.
|
// Relay is up but ICE is down — partially connected.
|
||||||
return guard.ConnStatusPartiallyConnected
|
return guard.ConnStatusPartiallyConnected
|
||||||
case iceUp && !in.relayTransportConnected:
|
case iceRunning && !in.relayTransportConnected:
|
||||||
// ICE is up and the shared relay transport is down — offers cannot restore it.
|
// ICE is up and the shared relay transport is down — offers cannot restore it.
|
||||||
return guard.ConnStatusPartiallyConnected
|
return guard.ConnStatusPartiallyConnected
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ type connStatusInputs struct {
|
|||||||
relayTransportConnected bool // the relay transport shared by all peers on that server is up
|
relayTransportConnected bool // the relay transport shared by all peers on that server is up
|
||||||
remoteSupportsICE bool // remote peer sent ICE credentials
|
remoteSupportsICE bool // remote peer sent ICE credentials
|
||||||
iceWorkerCreated bool // local WorkerICE exists (false in force-relay mode)
|
iceWorkerCreated bool // local WorkerICE exists (false in force-relay mode)
|
||||||
iceStatusConnecting bool // statusICE is anything other than Disconnected
|
iceStatusConnected bool // statusICE reports Connected
|
||||||
iceInProgress bool // a negotiation is currently in flight
|
iceInProgress bool // a negotiation is currently in flight
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ func TestEvalConnStatus_FullyAvailable(t *testing.T) {
|
|||||||
mutator: func(in *connStatusInputs) {
|
mutator: func(in *connStatusInputs) {
|
||||||
in.peerUsesRelay = true
|
in.peerUsesRelay = true
|
||||||
in.relayConnected = true
|
in.relayConnected = true
|
||||||
in.iceStatusConnecting = true
|
in.iceStatusConnected = true
|
||||||
},
|
},
|
||||||
want: guard.ConnStatusConnected,
|
want: guard.ConnStatusConnected,
|
||||||
},
|
},
|
||||||
@@ -132,7 +132,7 @@ func TestEvalConnStatus_FullyAvailable(t *testing.T) {
|
|||||||
mutator: func(in *connStatusInputs) {
|
mutator: func(in *connStatusInputs) {
|
||||||
in.peerUsesRelay = false
|
in.peerUsesRelay = false
|
||||||
in.relayConnected = false
|
in.relayConnected = false
|
||||||
in.iceStatusConnecting = true
|
in.iceStatusConnected = true
|
||||||
},
|
},
|
||||||
want: guard.ConnStatusConnected,
|
want: guard.ConnStatusConnected,
|
||||||
},
|
},
|
||||||
@@ -140,7 +140,7 @@ func TestEvalConnStatus_FullyAvailable(t *testing.T) {
|
|||||||
name: "ICE InProgress only, peer does NOT use relay",
|
name: "ICE InProgress only, peer does NOT use relay",
|
||||||
mutator: func(in *connStatusInputs) {
|
mutator: func(in *connStatusInputs) {
|
||||||
in.peerUsesRelay = false
|
in.peerUsesRelay = false
|
||||||
in.iceStatusConnecting = false
|
in.iceStatusConnected = false
|
||||||
in.iceInProgress = true
|
in.iceInProgress = true
|
||||||
},
|
},
|
||||||
want: guard.ConnStatusConnected,
|
want: guard.ConnStatusConnected,
|
||||||
@@ -150,7 +150,7 @@ func TestEvalConnStatus_FullyAvailable(t *testing.T) {
|
|||||||
mutator: func(in *connStatusInputs) {
|
mutator: func(in *connStatusInputs) {
|
||||||
in.peerUsesRelay = true
|
in.peerUsesRelay = true
|
||||||
in.relayConnected = true
|
in.relayConnected = true
|
||||||
in.iceStatusConnecting = false
|
in.iceStatusConnected = false
|
||||||
in.iceInProgress = false
|
in.iceInProgress = false
|
||||||
},
|
},
|
||||||
want: guard.ConnStatusPartiallyConnected,
|
want: guard.ConnStatusPartiallyConnected,
|
||||||
@@ -160,7 +160,7 @@ func TestEvalConnStatus_FullyAvailable(t *testing.T) {
|
|||||||
mutator: func(in *connStatusInputs) {
|
mutator: func(in *connStatusInputs) {
|
||||||
in.peerUsesRelay = false
|
in.peerUsesRelay = false
|
||||||
in.relayConnected = false
|
in.relayConnected = false
|
||||||
in.iceStatusConnecting = false
|
in.iceStatusConnected = false
|
||||||
in.iceInProgress = false
|
in.iceInProgress = false
|
||||||
},
|
},
|
||||||
want: guard.ConnStatusDisconnected,
|
want: guard.ConnStatusDisconnected,
|
||||||
@@ -171,7 +171,7 @@ func TestEvalConnStatus_FullyAvailable(t *testing.T) {
|
|||||||
in.peerUsesRelay = true
|
in.peerUsesRelay = true
|
||||||
in.relayConnected = false
|
in.relayConnected = false
|
||||||
in.relayTransportConnected = true
|
in.relayTransportConnected = true
|
||||||
in.iceStatusConnecting = true
|
in.iceStatusConnected = true
|
||||||
},
|
},
|
||||||
// The transport is fine, so the peer itself is unreachable over relay: it may have
|
// The transport is fine, so the peer itself is unreachable over relay: it may have
|
||||||
// moved to another server, and only an offer carries its new relay address.
|
// moved to another server, and only an offer carries its new relay address.
|
||||||
@@ -183,7 +183,7 @@ func TestEvalConnStatus_FullyAvailable(t *testing.T) {
|
|||||||
in.peerUsesRelay = true
|
in.peerUsesRelay = true
|
||||||
in.relayConnected = false
|
in.relayConnected = false
|
||||||
in.relayTransportConnected = false
|
in.relayTransportConnected = false
|
||||||
in.iceStatusConnecting = true
|
in.iceStatusConnected = true
|
||||||
},
|
},
|
||||||
// ICE carries the traffic and the relay transport is restored by the relay client's
|
// ICE carries the traffic and the relay transport is restored by the relay client's
|
||||||
// own guard, not by offers, so this must not trigger the aggressive retry.
|
// own guard, not by offers, so this must not trigger the aggressive retry.
|
||||||
@@ -195,7 +195,7 @@ func TestEvalConnStatus_FullyAvailable(t *testing.T) {
|
|||||||
in.peerUsesRelay = true
|
in.peerUsesRelay = true
|
||||||
in.relayConnected = false
|
in.relayConnected = false
|
||||||
in.relayTransportConnected = false
|
in.relayTransportConnected = false
|
||||||
in.iceStatusConnecting = false
|
in.iceStatusConnected = false
|
||||||
in.iceInProgress = false
|
in.iceInProgress = false
|
||||||
},
|
},
|
||||||
want: guard.ConnStatusDisconnected,
|
want: guard.ConnStatusDisconnected,
|
||||||
@@ -205,7 +205,7 @@ func TestEvalConnStatus_FullyAvailable(t *testing.T) {
|
|||||||
mutator: func(in *connStatusInputs) {
|
mutator: func(in *connStatusInputs) {
|
||||||
in.peerUsesRelay = false
|
in.peerUsesRelay = false
|
||||||
in.relayConnected = true // not actually used since peer doesn't rely on it
|
in.relayConnected = true // not actually used since peer doesn't rely on it
|
||||||
in.iceStatusConnecting = false
|
in.iceStatusConnected = false
|
||||||
in.iceInProgress = false
|
in.iceInProgress = false
|
||||||
},
|
},
|
||||||
want: guard.ConnStatusDisconnected,
|
want: guard.ConnStatusDisconnected,
|
||||||
|
|||||||
Reference in New Issue
Block a user