Skip to content

Homelabsio/wgctrl-js

 
 

Repository files navigation

wgctrl-js

npm Version Node.js GitHub License CI Status

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.

About

Wireguard Control API for Node.js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 58.4%
  • C++ 37.1%
  • Python 3.9%
  • JavaScript 0.6%