10 changed files with 46 additions and 157 deletions
@ -1,21 +1,12 @@ |
|||
import { exec } from "node:child_process"; |
|||
import { promisify } from "node:util"; |
|||
const promisifiedExec = promisify(exec); |
|||
import { runCommand } from "../Util"; |
|||
|
|||
/** |
|||
* Disable ufw. (root/sudo access is mandatory) |
|||
*/ |
|||
export default async function() { |
|||
try { |
|||
let res = await promisifiedExec(`echo "y" | sudo ufw disable`); |
|||
|
|||
if (res.stderr) throw new Error(res.stderr); |
|||
|
|||
if (res.stdout) { |
|||
return true; |
|||
} else { |
|||
return false; |
|||
}; |
|||
let command = await runCommand(`echo "y" | sudo ufw disable`); |
|||
return command !== null; |
|||
} catch (err) { |
|||
throw err; |
|||
}; |
|||
|
@ -1,19 +1,10 @@ |
|||
import { exec } from "node:child_process"; |
|||
import { promisify } from "node:util"; |
|||
const promisifiedExec = promisify(exec); |
|||
import { runCommand } from "../Util"; |
|||
|
|||
export default async function() { |
|||
try { |
|||
// https://serverfault.com/a/790150
|
|||
let res = await promisifiedExec(`echo "y" | sudo ufw enable`); |
|||
|
|||
if (res.stderr) throw new Error(res.stderr); |
|||
|
|||
if (res.stdout) { |
|||
return true; |
|||
} else { |
|||
return false; |
|||
}; |
|||
let command = await runCommand(`echo "y" | sudo ufw enable`); |
|||
return command !== null; |
|||
} catch (err) { |
|||
throw err; |
|||
}; |
|||
|
@ -1,22 +1,13 @@ |
|||
import { exec } from "node:child_process"; |
|||
import { promisify } from "node:util"; |
|||
import { runCommand } from "../Util"; |
|||
import type { LoggingType } from "../Typings"; |
|||
const promisifiedExec = promisify(exec); |
|||
|
|||
/** |
|||
* Set/toggle UFW logging. (root/sudo access is mandatory) |
|||
*/ |
|||
export default async function(type: LoggingType) { |
|||
try { |
|||
let res = await promisifiedExec(`sudo ufw logging ${type}`); |
|||
|
|||
if (res.stderr) throw new Error(res.stderr); |
|||
|
|||
if (res.stdout) { |
|||
return true; |
|||
} else { |
|||
return false; |
|||
}; |
|||
let command = await runCommand(`sudo ufw logging ${type}`); |
|||
return command !== null; |
|||
} catch (err) { |
|||
throw err; |
|||
}; |
|||
|
@ -1,21 +1,12 @@ |
|||
import { exec } from "node:child_process"; |
|||
import { promisify } from "node:util"; |
|||
const promisifiedExec = promisify(exec); |
|||
import { runCommand } from "../Util"; |
|||
|
|||
/** |
|||
* Reloads firewall. (root/sudo access is mandatory) |
|||
*/ |
|||
export default async function() { |
|||
try { |
|||
let res = await promisifiedExec("sudo ufw reload"); |
|||
|
|||
if (res.stderr) throw new Error(res.stderr); |
|||
|
|||
if (res.stdout) { |
|||
return true; |
|||
} else { |
|||
return false; |
|||
}; |
|||
let command = await runCommand("sudo ufw reload"); |
|||
return command !== null; |
|||
} catch (err) { |
|||
throw err; |
|||
}; |
|||
|
@ -1,21 +1,12 @@ |
|||
import { exec } from "node:child_process"; |
|||
import { promisify } from "node:util"; |
|||
const promisifiedExec = promisify(exec); |
|||
import { runCommand } from "../Util"; |
|||
|
|||
/** |
|||
* Disables and resets firewall to installation defaults. No prompt. Use this wisely. (root/sudo access is mandatory)= |
|||
*/ |
|||
export default async function() { |
|||
try { |
|||
let res = await promisifiedExec("sudo ufw --force reset"); |
|||
|
|||
if (res.stderr) throw new Error(res.stderr); |
|||
|
|||
if (res.stdout) { |
|||
return true; |
|||
} else { |
|||
return false; |
|||
}; |
|||
let command = await runCommand("sudo ufw --force reset"); |
|||
return command !== null; |
|||
} catch (err) { |
|||
throw err; |
|||
}; |
|||
|
Loading…
Reference in new issue