mirror of
https://github.com/WeeJeWel/wg-easy.git
synced 2025-02-23 16:44:58 +08:00
wip
This commit is contained in:
parent
cb17ba5ebd
commit
30f56510e6
@ -5,6 +5,7 @@ const childProcess = require('child_process');
|
|||||||
module.exports = class Util {
|
module.exports = class Util {
|
||||||
|
|
||||||
static promisify(fn) {
|
static promisify(fn) {
|
||||||
|
// eslint-disable-next-line func-names
|
||||||
return function(req, res) {
|
return function(req, res) {
|
||||||
Promise.resolve().then(async () => fn(req, res))
|
Promise.resolve().then(async () => fn(req, res))
|
||||||
.then(result => {
|
.then(result => {
|
||||||
@ -39,6 +40,9 @@ module.exports = class Util {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async exec(cmd) {
|
static async exec(cmd) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(`$ ${cmd}`);
|
||||||
|
|
||||||
if (process.platform !== 'linux') {
|
if (process.platform !== 'linux') {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,10 @@ module.exports = class WireGuard {
|
|||||||
|
|
||||||
await this.__saveConfig(config);
|
await this.__saveConfig(config);
|
||||||
await Util.exec('wg-quick up wg0');
|
await Util.exec('wg-quick up wg0');
|
||||||
|
await Util.exec(`iptables -t nat -A POSTROUTING -s ${WG_DEFAULT_ADDRESS.replace('x', '0')}/24 -o eth0 -j MASQUERADE`);
|
||||||
|
await Util.exec('iptables -A INPUT -p udp -m udp --dport 51820 -j ACCEPT');
|
||||||
|
await Util.exec('iptables -A FORWARD -i wg0 -j ACCEPT');
|
||||||
|
await Util.exec('iptables -A FORWARD -o wg0 -j ACCEPT');
|
||||||
await this.__syncConfig();
|
await this.__syncConfig();
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
|
@ -27,6 +27,6 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "16"
|
"node": "14"
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user