@homelabsio/wgctrl
v0.0.2
Published
WireGuard Control API for Node.js
Downloads
1
Readme
wgctrl-js
Wireguard control API for Node.js
Install
npm install @homelabsio/wgctrl
Runtime Requirements
@homelabsio/wgctrl performs various network configuration tasks which require that the node process either:
- be executing as root [NOT PREFERRED]
OR - have CAP_NET_ADMIN [PREFERRED]
Usage
Modify existing Wireguard device
import { Peer, Device, getDevices, getDevice, setDevice } from '@homelabsio/wgctrl';
// Get array of current WireGuard devices
let devs: string[] = getDevices();
console.log (devs); // [ 'wg0', 'wg1', 'wg2' ]
const wg0: Device = getDevice('');
let newPeer: Peer = new Peer('BCBqOfgqPK2RQO+z1QPYHvlxcOG41m2385dvjJcj5mE=');
newPeer.endpoint = "203.0.113.0:51820";
newPeer.presharedKey = "QJa8/fxAxEZtbaWrQ1UOrkGc2Gzx+O/DbhYzYcICPew=";
newPeer.persistentKeepaliveInterval = 25;
newPeer.addAllowedIP("198.19.254.250/32");
newPeer.addAllowedIP("198.19.254.252");
wg.addPeer(newPeer);
setDevice(wg0);
Testing
npm run format
npm run lint
npm run test
See Also
- TODO
Legal
@homelabsio/wgctrl is licensed under the terms of the MIT License. See the license file for details.