Browse Source

localIp added to QR code

pull/468/head
tm-sanjay 4 years ago
parent
commit
cc4c68ad00
  1. 2
      src/config.js
  2. 9
      src/lib/WireGuard.js

2
src/config.js

@ -9,7 +9,7 @@ module.exports.WG_PATH = process.env.WG_PATH || '/etc/wireguard/';
module.exports.WG_HOST = process.env.WG_HOST || '0.0.0.0';
module.exports.WG_PORT = process.env.WG_PORT || 51820;
module.exports.WG_MTU = process.env.WG_MTU || null;
module.exports.WG_PERSISTENT_KEEPALIVE = process.env.WG_PERSISTENT_KEEPALIVE || 0;
module.exports.WG_PERSISTENT_KEEPALIVE = process.env.WG_PERSISTENT_KEEPALIVE || 25;
module.exports.WG_DEFAULT_ADDRESS = process.env.WG_DEFAULT_ADDRESS || '10.8.0.x';
module.exports.WG_DEFAULT_DNS = typeof process.env.WG_DEFAULT_DNS === 'string'
? process.env.WG_DEFAULT_DNS

9
src/lib/WireGuard.js

@ -191,9 +191,16 @@ AllowedIPs = ${client.address}/32`;
return client;
}
//get local ip
static async getLocalIP() {
var ip = await Util.exec('hostname -I');
return ip.split(' ')[0];
}
async getClientConfiguration({ clientId }) {
const config = await this.getConfig();
const client = await this.getClient({ clientId });
const localIP = await WireGuard.getLocalIP();
return `
[Interface]
@ -206,7 +213,7 @@ ${WG_MTU ? `MTU = ${WG_MTU}` : ''}
PublicKey = ${config.server.publicKey}
AllowedIPs = ${WG_ALLOWED_IPS}
PersistentKeepalive = ${WG_PERSISTENT_KEEPALIVE}
Endpoint = ${WG_HOST}:${WG_PORT}`;
Endpoint = ${localIP}:${WG_PORT}`;
}
async getClientQRCodeSVG({ clientId }) {

Loading…
Cancel
Save