Wireguard control API for Node.js
npm install @homelabsio/wgctrl
@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]
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);
npm run format
npm run lint
npm run test
- TODO
@homelabsio/wgctrl is licensed under the terms of the MIT License. See the license file for details.