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