fix: harden mac nordvpn status inference
This commit is contained in:
@@ -417,6 +417,39 @@ function normalizeSuccessfulConnectState(state, connectResult, verified) {
|
||||
};
|
||||
}
|
||||
|
||||
function normalizeStatusState(state) {
|
||||
if (
|
||||
!state ||
|
||||
state.platform !== "darwin" ||
|
||||
state.controlMode !== "wireguard" ||
|
||||
state.connected ||
|
||||
!state.wireguard ||
|
||||
state.wireguard.active ||
|
||||
!state.wireguard.endpoint ||
|
||||
!state.wireguard.lastConnection ||
|
||||
!state.publicIp ||
|
||||
!state.publicIp.ok
|
||||
) {
|
||||
return state;
|
||||
}
|
||||
|
||||
const target =
|
||||
state.wireguard.lastConnection.resolvedTarget ||
|
||||
state.wireguard.lastConnection.requestedTarget;
|
||||
if (!target || !locationMatches(state.publicIp, target)) {
|
||||
return state;
|
||||
}
|
||||
|
||||
return {
|
||||
...state,
|
||||
connected: true,
|
||||
wireguard: {
|
||||
...state.wireguard,
|
||||
active: true,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function fetchJson(url, headers = {}) {
|
||||
return new Promise((resolve) => {
|
||||
const targetUrl = new URL(url);
|
||||
@@ -1293,7 +1326,7 @@ async function main() {
|
||||
try {
|
||||
if (action === "status") {
|
||||
const ipInfo = await getPublicIpInfo();
|
||||
emitJson(buildStateSummary(installProbe, ipInfo));
|
||||
emitJson(normalizeStatusState(buildStateSummary(installProbe, ipInfo)));
|
||||
}
|
||||
|
||||
if (action === "install") {
|
||||
|
||||
Reference in New Issue
Block a user