wip
This commit is contained in:
parent
d8f45476da
commit
650128cacb
|
@ -15,7 +15,6 @@ const {
|
||||||
PASSWORD,
|
PASSWORD,
|
||||||
} = require('../config');
|
} = require('../config');
|
||||||
|
|
||||||
WireGuard.getClients().then(console.log);
|
|
||||||
module.exports = class Server {
|
module.exports = class Server {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { rejects } = require('assert');
|
||||||
|
const childProcess = require('child_process');
|
||||||
|
const { resolve } = require('path');
|
||||||
|
|
||||||
module.exports = class Util {
|
module.exports = class Util {
|
||||||
|
|
||||||
static requireSession(req, res, next) {
|
static requireSession(req, res, next) {
|
||||||
|
@ -43,4 +47,17 @@ module.exports = class Util {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static async exec(cmd) {
|
||||||
|
if (process.platform !== 'linux') {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
childProcess.exec(cmd, (err, stdout) => {
|
||||||
|
if (err) return reject(err);
|
||||||
|
return resolve(stdout);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -90,9 +90,9 @@ AllowedIPs = ${client.allowedIPs}`;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Loop WireGuard status
|
// Loop WireGuard status
|
||||||
// const clientsDump = await Util.exec('wg show wg0 dump');
|
const clientsDump = await Util.exec('wg show wg0 dump');
|
||||||
const clientsDump = `iOQJS7OUUGPYATsX6nqlL+sOODoiWiN5IOE8Msfw/0o= BkdntwYazhYZzEEHhcYayq6TGw9/YUDQ251s+5bTgC0= 51820 off
|
// const clientsDump = `iOQJS7OUUGPYATsX6nqlL+sOODoiWiN5IOE8Msfw/0o= BkdntwYazhYZzEEHhcYayq6TGw9/YUDQ251s+5bTgC0= 51820 off
|
||||||
i8xWKqicnDkNL14I4B+I1zlB8od/booA1joIosWn7X4= MzplKtOQ44/IaAKri2VKqCoIlg4XiVH7TCp5bcYRTQU= 172.17.0.1:60475 10.8.0.2/32 1621679257 7920 7440 off`;
|
// i8xWKqicnDkNL14I4B+I1zlB8od/booA1joIosWn7X4= MzplKtOQ44/IaAKri2VKqCoIlg4XiVH7TCp5bcYRTQU= 172.17.0.1:60475 10.8.0.2/32 1621679257 7920 7440 off`;
|
||||||
clientsDump
|
clientsDump
|
||||||
.trim()
|
.trim()
|
||||||
.split('\n')
|
.split('\n')
|
||||||
|
@ -100,9 +100,9 @@ i8xWKqicnDkNL14I4B+I1zlB8od/booA1joIosWn7X4= MzplKtOQ44/IaAKri2VKqCoIlg4XiVH7TCp
|
||||||
.forEach(line => {
|
.forEach(line => {
|
||||||
const [
|
const [
|
||||||
publicKey,
|
publicKey,
|
||||||
preSharedKey,
|
preSharedKey, // eslint-disable-line no-unused-vars
|
||||||
endpoint,
|
endpoint,
|
||||||
allowedIps,
|
allowedIps, // eslint-disable-line no-unused-vars
|
||||||
latestHandshakeAt,
|
latestHandshakeAt,
|
||||||
transferRx,
|
transferRx,
|
||||||
transferTx,
|
transferTx,
|
||||||
|
@ -110,7 +110,6 @@ i8xWKqicnDkNL14I4B+I1zlB8od/booA1joIosWn7X4= MzplKtOQ44/IaAKri2VKqCoIlg4XiVH7TCp
|
||||||
] = line.split('\t');
|
] = line.split('\t');
|
||||||
|
|
||||||
const client = clients.find(client => client.publicKey === publicKey);
|
const client = clients.find(client => client.publicKey === publicKey);
|
||||||
console.log({ publicKey, client });
|
|
||||||
if (!client) return;
|
if (!client) return;
|
||||||
|
|
||||||
client.endpoint = endpoint === '(none)'
|
client.endpoint = endpoint === '(none)'
|
||||||
|
@ -124,8 +123,6 @@ i8xWKqicnDkNL14I4B+I1zlB8od/booA1joIosWn7X4= MzplKtOQ44/IaAKri2VKqCoIlg4XiVH7TCp
|
||||||
client.persistentKeepalive = persistentKeepalive;
|
client.persistentKeepalive = persistentKeepalive;
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('clients', clients);
|
|
||||||
|
|
||||||
return clients;
|
return clients;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue