Maneger Wireguard interface directly from node (and create you APIs) https://www.npmjs.com/package/wireguard-tools.js
Go to file
Matheus Sampaio Queiroga e5542dd8b4
All checks were successful
Test / Test Linux (20.x) (pull_request) Successful in 1m18s
Test / Test Linux (21.x) (pull_request) Successful in 1m16s
Test / Test Linux (18.x) (pull_request) Successful in 1m21s
Test / Test Linux (latest) (pull_request) Successful in 1m23s
Update packages and add updateInterface
Signed-off-by: Matheus Sampaio Queiroga <srherobrine20@gmail.com>
2024-11-08 11:49:16 -03:00
.devcontainer Update README and vscode configs 2024-02-20 15:51:14 -03:00
.github Droping rebory and migrate to cmake-js (#14) 2024-07-09 00:07:04 -03:00
.vscode Droping rebory and migrate to cmake-js (#14) 2024-07-09 00:07:04 -03:00
.zed Clean code for userspace 2024-07-11 20:35:12 -03:00
addon Clean code for userspace 2024-07-11 20:35:12 -03:00
src Update packages and add updateInterface 2024-11-08 11:49:16 -03:00
.gitignore Big code refactoring (#10) 2024-03-15 04:08:26 +00:00
.npmignore Droping rebory and migrate to cmake-js (#14) 2024-07-09 00:07:04 -03:00
CMakeLists.txt Update packages and add updateInterface 2024-11-08 11:49:16 -03:00
compile_flags.txt Clean code for userspace 2024-07-11 20:35:12 -03:00
LICENSE Remove .ts files, migrate to vanilla javascript 2023-09-12 00:35:32 -03:00
package.json Update packages and add updateInterface 2024-11-08 11:49:16 -03:00
README.md Droping rebory and migrate to cmake-js (#14) 2024-07-09 00:07:04 -03:00
tsconfig.json Droping rebory and migrate to cmake-js (#14) 2024-07-09 00:07:04 -03:00

Wireguard-tools for Nodejs

Manage your Wireguard interfaces directly from Node.js without any wrappers over wg or wg-quick

Warning

Require cmake and tools (GCC/GCC++, clang or Visual Studio) to build this addon

New versions does't include prebuilt binaries

import { setConfig, getConfig, key, Config } from "../index.js"

const tunName = process.platform === "darwin" ? "utun10" : "wg3" // Tunnel name, in MacOS/Darwin require start with utun prefix
let currentConfig: Config
try {
  currentConfig = await getConfig(tunName) // Check if exists tun
} catch {
  // Create new wireguard tun
  currentConfig = {
    name: tunName,
    privateKey: await key.privateKey(),
    portListen: 5820,
    address: [
      "10.66.66.1/24"
    ],
    peers: {}
  }
}

// Add new Peer
const peerPrivate = await key.privateKey()
currentConfig.peers[key.publicKey(peerPrivate)] = {
  presharedKey: await key.presharedKey(),
  allowedIPs: [
    "10.66.66.2/24"
  ]
}

// Deploy new Config
await setConfig(currentConfig)

Licences

  • Wireguard-tools.js: GPL-3.0

Wireguard

  • Embeddable-wg-library: LGPL-2.1+.
  • Wireguard-nt: GPL-2.0
  • Wireguard-go: MIT