Keep verified Gateway active through transient discovery failures
This commit is contained in:
@@ -190,10 +190,16 @@ export function applyGatewayPreference(state, enabled) {
|
||||
export function nextGatewayAutoState(current, {
|
||||
network,
|
||||
verifiedGateway = null,
|
||||
failureLimit = 3,
|
||||
error = 'Gateway presence check failed',
|
||||
}) {
|
||||
if (!network) return createGatewayAutoState();
|
||||
if (!network) {
|
||||
if (!current.gatewayId) return createGatewayAutoState();
|
||||
return {
|
||||
...current,
|
||||
failures: current.failures + 1,
|
||||
lastError: String(error || 'Gateway presence check failed'),
|
||||
};
|
||||
}
|
||||
|
||||
const routeChanged = !sameGatewayRoute(current.gateway, network);
|
||||
const base = routeChanged
|
||||
@@ -215,11 +221,8 @@ export function nextGatewayAutoState(current, {
|
||||
const failures = base.failures + 1;
|
||||
return {
|
||||
...base,
|
||||
mode: base.mode === 'gateway-direct' && failures < failureLimit
|
||||
? 'gateway-direct'
|
||||
: 'local-vpn',
|
||||
mode: base.gatewayId ? 'gateway-direct' : 'local-vpn',
|
||||
failures,
|
||||
gatewayId: failures < failureLimit ? base.gatewayId : '',
|
||||
lastError: String(error || 'Gateway presence check failed'),
|
||||
};
|
||||
}
|
||||
|
||||
+11
-4
@@ -302,10 +302,17 @@ function refreshGatewayAutoMode({ reconfigure = true } = {}) {
|
||||
: null;
|
||||
|
||||
if (!network) {
|
||||
const nextState = nextGatewayAutoState(gatewayAutoState, { network: null });
|
||||
if (state.subscriptionUrl) {
|
||||
nextState.lastError = 'macOS default gateway недоступен или устарел';
|
||||
}
|
||||
const discoveryError = 'macOS default gateway недоступен или устарел';
|
||||
const discoveredState = nextGatewayAutoState(gatewayAutoState, {
|
||||
network: null,
|
||||
error: discoveryError,
|
||||
});
|
||||
const nextState = applyGatewayPreference(
|
||||
state.subscriptionUrl
|
||||
? { ...discoveredState, lastError: discoveryError }
|
||||
: discoveredState,
|
||||
state.gatewayAutoEnabled !== false,
|
||||
);
|
||||
await applyGatewayAutoState(
|
||||
nextState,
|
||||
{ reconfigure },
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
export const HARBOR_VERSIONS = Object.freeze({
|
||||
macClient: '0.8.11',
|
||||
macClient: '0.8.12',
|
||||
gatewayClient: '0.8.10',
|
||||
gatewayBackend: '0.8.0',
|
||||
gatewayBackend: '0.8.1',
|
||||
});
|
||||
|
||||
export function parseVersion(value) {
|
||||
|
||||
Reference in New Issue
Block a user