@khemsok/tunl 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +4 -22
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -57341,11 +57341,9 @@ function restoreBrowserDNS() {
|
|
|
57341
57341
|
}
|
|
57342
57342
|
|
|
57343
57343
|
// src/lib/sudo-setup.ts
|
|
57344
|
-
import { existsSync as existsSync8,
|
|
57344
|
+
import { existsSync as existsSync8, writeFileSync as writeFileSync5 } from "fs";
|
|
57345
57345
|
import { execSync as execSync4 } from "child_process";
|
|
57346
57346
|
import { userInfo } from "os";
|
|
57347
|
-
var SUDOERS_PATH = "/etc/sudoers.d/tunl";
|
|
57348
|
-
var SUDOERS_VERSION = "2";
|
|
57349
57347
|
function buildRules() {
|
|
57350
57348
|
const username = userInfo().username;
|
|
57351
57349
|
return [
|
|
@@ -57361,20 +57359,13 @@ function buildRules() {
|
|
|
57361
57359
|
].join(`
|
|
57362
57360
|
`);
|
|
57363
57361
|
}
|
|
57362
|
+
var SUDOERS_PATH = "/etc/sudoers.d/tunl";
|
|
57364
57363
|
function sudoersInstalled() {
|
|
57365
|
-
|
|
57366
|
-
return false;
|
|
57367
|
-
try {
|
|
57368
|
-
const content = readFileSync4(SUDOERS_PATH, "utf-8");
|
|
57369
|
-
return content.includes(`# tunl-version: ${SUDOERS_VERSION}`);
|
|
57370
|
-
} catch {
|
|
57371
|
-
return false;
|
|
57372
|
-
}
|
|
57364
|
+
return existsSync8(SUDOERS_PATH);
|
|
57373
57365
|
}
|
|
57374
57366
|
function installSudoers() {
|
|
57375
57367
|
const rules = buildRules();
|
|
57376
57368
|
const content = `# tunl - terminal focus timer
|
|
57377
|
-
# tunl-version: ${SUDOERS_VERSION}
|
|
57378
57369
|
# allows site blocking without password prompts
|
|
57379
57370
|
${rules}
|
|
57380
57371
|
`;
|
|
@@ -57481,16 +57472,7 @@ async function main2() {
|
|
|
57481
57472
|
`);
|
|
57482
57473
|
}
|
|
57483
57474
|
if (!args.noblock) {
|
|
57484
|
-
|
|
57485
|
-
if (needsRestart) {
|
|
57486
|
-
console.log(`
|
|
57487
|
-
\u25C9 tunl \u2014 first-time setup
|
|
57488
|
-
`);
|
|
57489
|
-
console.log(" Disabled browser built-in DNS so site blocking works.");
|
|
57490
|
-
console.log(" Please restart your browser (Chrome/Arc/Edge) for this to take effect.");
|
|
57491
|
-
console.log(` This only needs to happen once.
|
|
57492
|
-
`);
|
|
57493
|
-
}
|
|
57475
|
+
setupBrowserDNS();
|
|
57494
57476
|
if (!sudoersInstalled()) {
|
|
57495
57477
|
console.log(`
|
|
57496
57478
|
\u25C9 tunl \u2014 setup
|