diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index bd4a836d..d1b7cf66 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -13,5 +13,5 @@ services: - NET_ADMIN - SYS_MODULE environment: - # - PASSWORD=p + # - PASSWORD_HASH=p - WG_HOST=192.168.1.233 diff --git a/src/config.js b/src/config.js index 97850537..eb06a4b4 100644 --- a/src/config.js +++ b/src/config.js @@ -5,6 +5,8 @@ const { release: { version } } = require('./package.json'); module.exports.RELEASE = version; module.exports.PORT = process.env.PORT || '51821'; module.exports.WEBUI_HOST = process.env.WEBUI_HOST || '0.0.0.0'; +/** This is only kept for migration purpose. DO NOT USE! */ +module.exports.PASSWORD = process.env.PASSWORD; module.exports.PASSWORD_HASH = process.env.PASSWORD_HASH; module.exports.WG_PATH = process.env.WG_PATH || '/etc/wireguard/'; module.exports.WG_DEVICE = process.env.WG_DEVICE || 'eth0'; diff --git a/src/lib/Server.js b/src/lib/Server.js index 7f06da50..b2ee2e9d 100644 --- a/src/lib/Server.js +++ b/src/lib/Server.js @@ -28,6 +28,7 @@ const { PORT, WEBUI_HOST, RELEASE, + PASSWORD, PASSWORD_HASH, LANG, UI_TRAFFIC_STATS, @@ -306,6 +307,10 @@ module.exports = class Server { }), ); + if (PASSWORD) { + throw new Error('DO NOT USE PASSWORD ENVIRONMENT VARIABLE. USE PASSWORD_HASH INSTEAD.\nSee https://github.com/wg-easy/wg-easy/blob/master/How_to_generate_an_bcrypt_hash.md'); + } + createServer(toNodeListener(app)).listen(PORT, WEBUI_HOST); debug(`Listening on http://${WEBUI_HOST}:${PORT}`); }