fix: simplify mac nordvpn tailscale coordination
This commit is contained in:
@@ -9,10 +9,16 @@ function loadInternals() {
|
||||
const source = fs.readFileSync(scriptPath, "utf8").replace(/\nmain\(\);\s*$/, "\n");
|
||||
const wrapped = `${source}
|
||||
module.exports = {
|
||||
buildMacTailscaleState:
|
||||
typeof buildMacTailscaleState === "function" ? buildMacTailscaleState : undefined,
|
||||
buildWireguardConfig:
|
||||
typeof buildWireguardConfig === "function" ? buildWireguardConfig : undefined,
|
||||
buildLookupResult:
|
||||
typeof buildLookupResult === "function" ? buildLookupResult : undefined,
|
||||
getMacTailscalePath:
|
||||
typeof getMacTailscalePath === "function" ? getMacTailscalePath : undefined,
|
||||
isMacTailscaleActive:
|
||||
typeof isMacTailscaleActive === "function" ? isMacTailscaleActive : undefined,
|
||||
detectMacWireguardActiveFromIfconfig:
|
||||
typeof detectMacWireguardActiveFromIfconfig === "function" ? detectMacWireguardActiveFromIfconfig : undefined,
|
||||
resolveHostnameWithFallback:
|
||||
@@ -62,7 +68,7 @@ test("buildLookupResult supports lookup all=true mode", () => {
|
||||
assert.equal(JSON.stringify(buildLookupResult("104.26.9.44", { all: false })), JSON.stringify(["104.26.9.44", 4]));
|
||||
});
|
||||
|
||||
test("buildWireguardConfig omits DNS so macOS wg-quick does not rewrite system resolvers", () => {
|
||||
test("buildWireguardConfig includes NordVPN DNS for the vanilla macOS config path", () => {
|
||||
const { buildWireguardConfig } = loadInternals();
|
||||
assert.equal(typeof buildWireguardConfig, "function");
|
||||
|
||||
@@ -75,10 +81,40 @@ test("buildWireguardConfig omits DNS so macOS wg-quick does not rewrite system r
|
||||
"PRIVATEKEY"
|
||||
);
|
||||
|
||||
assert.equal(config.includes("DNS ="), false);
|
||||
assert.equal(config.includes("DNS = 103.86.96.100, 103.86.99.100"), true);
|
||||
assert.equal(config.includes("AllowedIPs = 0.0.0.0/0"), true);
|
||||
});
|
||||
|
||||
test("getMacTailscalePath falls back to /opt/homebrew/bin/tailscale when PATH lookup is missing", () => {
|
||||
const { getMacTailscalePath } = loadInternals();
|
||||
assert.equal(typeof getMacTailscalePath, "function");
|
||||
assert.equal(
|
||||
getMacTailscalePath({
|
||||
commandExists: () => "",
|
||||
fileExists: (target) => target === "/opt/homebrew/bin/tailscale",
|
||||
}),
|
||||
"/opt/homebrew/bin/tailscale"
|
||||
);
|
||||
});
|
||||
|
||||
test("buildMacTailscaleState records whether tailscale was active", () => {
|
||||
const { buildMacTailscaleState } = loadInternals();
|
||||
assert.equal(typeof buildMacTailscaleState, "function");
|
||||
assert.equal(
|
||||
JSON.stringify(buildMacTailscaleState(true)),
|
||||
JSON.stringify({
|
||||
tailscaleWasActive: true,
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
test("isMacTailscaleActive treats Running backend as active", () => {
|
||||
const { isMacTailscaleActive } = loadInternals();
|
||||
assert.equal(typeof isMacTailscaleActive, "function");
|
||||
assert.equal(isMacTailscaleActive({ BackendState: "Running" }), true);
|
||||
assert.equal(isMacTailscaleActive({ BackendState: "Stopped" }), false);
|
||||
});
|
||||
|
||||
test("verifyConnectionWithRetry retries transient reachability failures", async () => {
|
||||
const { verifyConnectionWithRetry } = loadInternals();
|
||||
assert.equal(typeof verifyConnectionWithRetry, "function");
|
||||
|
||||
Reference in New Issue
Block a user