This commit is contained in:
Emile Nijssen 2021-05-23 12:25:14 +02:00
parent 9c34761578
commit e3b7d94fa0
7 changed files with 59 additions and 4 deletions

View file

@ -3,7 +3,7 @@
module.exports.PORT = process.env.PORT || 51821;
module.exports.PASSWORD = process.env.PASSWORD;
module.exports.WG_PATH = process.env.WG_PATH || '/etc/wireguard/';
module.exports.WG_HOST = process.env.WG_HOST || '127.0.0.1';
module.exports.WG_HOST = process.env.WG_HOST;
module.exports.WG_PORT = process.env.WG_PORT || 51820;
module.exports.WG_DEFAULT_ADDRESS = process.env.WG_DEFAULT_ADDRESS || '10.8.0.x';
module.exports.WG_DEFAULT_DNS = process.env.WG_DEFAULT_DNS || '1.1.1.1';

View file

@ -22,6 +22,10 @@ module.exports = class WireGuard {
async getConfig() {
if (!this.__configPromise) {
this.__configPromise = Promise.resolve().then(async () => {
if (!WG_HOST) {
throw new Error('WG_HOST Environment Variable Not Set!');
}
let config;
try {
config = await fs.readFile(path.join(WG_PATH, 'wg0.json'), 'utf8');

View file

@ -4,7 +4,7 @@
"description": "",
"main": "server.js",
"scripts": {
"serve": "DEBUG=Server WG_PATH=../config/ nodemon server.js",
"serve": "DEBUG=Server WG_HOST=0.0.0.0 WG_PATH=../config/ nodemon server.js",
"serve-with-password": "PASSWORD=wg npm run serve"
},
"author": "Emile Nijssen",

View file

@ -2,4 +2,4 @@
const Server = require('../lib/Server');
module.exports = new Server();
module.exports = new Server();