From 1c9d30aa21066fdab45a86316e7521564533a280 Mon Sep 17 00:00:00 2001 From: Matheus Sampaio Queiroga Date: Tue, 20 Feb 2024 15:51:14 -0300 Subject: [PATCH] Update README and vscode configs --- .devcontainer/devcontainer.json | 17 ++++++++++++++++- .npmignore | 3 --- .vscode/extensions.json | 6 +++++- .vscode/settings.json | 3 --- README.md | 14 +++++++------- addons/tools/wginterface-win.cpp | 2 +- package.json | 2 +- src/quick.ts | 4 ++-- src/quick_test.ts | 2 +- 9 files changed, 33 insertions(+), 20 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 3780336..1eab0e9 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,8 +1,23 @@ { - "name": "rebory linux devcontainer", + "name": "wg.js devcontainer", "updateRemoteUserUID": false, "containerUser": "develop", "remoteUser": "develop", + "runArgs": [ + "--init" + ], + "privileged": true, + "customizations": { + "vscode": { + "extensions": [ + "github.vscode-github-actions", + "ms-vscode.cpptools", + "eamodio.gitlens", + "euskadi31.json-pretty-printer", + "redhat.vscode-yaml" + ] + } + }, "build": { "dockerfile": "Dockerfile", "args": { diff --git a/.npmignore b/.npmignore index acabee7..fe51b68 100644 --- a/.npmignore +++ b/.npmignore @@ -16,9 +16,6 @@ src/**/*.ts .github/ .git* -# node-gyp -build/**/* - # Project .vscode-ctags* *.addrs.json \ No newline at end of file diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 899b2b2..c637866 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,5 +1,9 @@ { "recommendations": [ - "ms-vscode.cpptools" + "github.vscode-github-actions", + "ms-vscode.cpptools", + "eamodio.gitlens", + "euskadi31.json-pretty-printer", + "redhat.vscode-yaml" ] } \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 4228333..977f74e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,6 @@ { "files.eol": "\n", "files.encoding": "utf8", - "files.defaultLanguage": "javascript", "files.trimFinalNewlines": true, "files.trimTrailingWhitespace": true, "editor.tabSize": 2, @@ -24,8 +23,6 @@ "PATH": "${workspaceFolder}/node_modules/.bin:${env:PATH}" }, "files.associations": { - "*.dsc": "ini", - "*.gyp": "python", "random": "cpp", "limits": "cpp", "xstring": "cpp" diff --git a/README.md b/README.md index db1c7d1..3521576 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,10 @@ Efficiently manage your Wireguard interface right from nodejs, no `wg` required. other tools are wrappers over `wg`, `wireguard-tools.js` is not like that, it is a `C/C++` addon in which you don't need to have `wg` installed, as this module has full compatibility of its own `wg`. +## CommonJS droping support + +With a small disappointment I come to inform you that CommonJS will be ignored in the next updates and will be completely an ESM module, if you don't want to migrate to ESM I recommend staying on version `1.8.1` or even `1.8.3`, which will be the last versions but recent in CommonJS. + ## Support to: - Userspace [(wireguard-go)](https://git.zx2c4.com/wireguard-go/about/) support. @@ -12,15 +16,11 @@ other tools are wrappers over `wg`, `wireguard-tools.js` is not like that, it is - [wg-quick](https://man7.org/linux/man-pages/man8/wg-quick.8.html) file support. - More info and example check [`wiki`](https://sirherobrine23.org/Wireguard/Wireguard-tools.js/wiki). -> **Note** +> [!NOTE] > > we have pre-copiled files for: -> - `Windows`: x64, arm64 -> - `MacOS`: x64/intel, arm64/Apple silicon > - `Linux`: x64/amd64, arm64/aarch64 -> -> else arch and system require copiler supported by `node-gyp` installed to compile Node addon. +> - `Windows`: x64, arm64 > > 1. To manage the Wireguard interfaces in linux, root access is required. -> 1. Windows user are `wireguard-nt` dll files includes in module -> 1. Another system's require `wireguard-go` [(check this page)](https://github.com/WireGuard/wireguard-go) +> 1. Another system's require `wireguard-go` [(check this page)](https://github.com/WireGuard/wireguard-go) \ No newline at end of file diff --git a/addons/tools/wginterface-win.cpp b/addons/tools/wginterface-win.cpp index ba94505..8120e62 100644 --- a/addons/tools/wginterface-win.cpp +++ b/addons/tools/wginterface-win.cpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include @@ -25,6 +24,7 @@ #include #include #include "wginterface.hh" +#include "win/shared.cpp" #include const DEVPROPKEY devpkey_name = { { 0x65726957, 0x7547, 0x7261, { 0x64, 0x4e, 0x61, 0x6d, 0x65, 0x4b, 0x65, 0x79 } }, DEVPROPID_FIRST_USABLE + 1 }; diff --git a/package.json b/package.json index 813a659..f05693d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wireguard-tools.js", - "version": "1.8.3", + "version": "2.0.0", "description": "Control your wireguard interface from node.js, not a wireguard-tools/wg wrapper!", "private": false, "type": "module", diff --git a/src/quick.ts b/src/quick.ts index f8fa669..2305b5f 100644 --- a/src/quick.ts +++ b/src/quick.ts @@ -53,7 +53,7 @@ export function parse(configString: string) { if (Array.isArray(interfaceConfig.postdown)) config.PostDown = interfaceConfig.postdown; if (Array.isArray(interfaceConfig.preup)) config.PreUp = interfaceConfig.preup; if (Array.isArray(interfaceConfig.predown)) config.PreDown = interfaceConfig.predown; - if (Array.isArray(interfaceConfig.address)) config.Address = interfaceConfig.address; + if (Array.isArray(interfaceConfig.address)) config.address = interfaceConfig.address; config.peers = {}; peers.forEach(({ publickey, presharedkey, endpoint, keepinterval, allowedips }) => { @@ -76,7 +76,7 @@ export function stringify(wgConfig: QuickConfig): string { let configStr: string[] = ["[Interface]"]; if (wgConfig.portListen >= 0) configStr.push(format("ListenPort = %s", wgConfig.portListen)); - if (wgConfig.Address) configStr.push(format("Address = %s", wgConfig.Address.join(", "))); + if (wgConfig.address) configStr.push(format("Address = %s", wgConfig.address.join(", "))); if (wgConfig.privateKey) configStr.push(format("PrivateKey = %s", wgConfig.privateKey)); if (wgConfig.publicKey) configStr.push(format("PublicKey = %s", wgConfig.publicKey)); if (wgConfig.Table > 0) configStr.push(format("Table = %s", wgConfig.Table)); diff --git a/src/quick_test.ts b/src/quick_test.ts index 0dd524f..2952c18 100644 --- a/src/quick_test.ts +++ b/src/quick_test.ts @@ -32,7 +32,7 @@ const StaticConfigJson: QuickConfig = { PreDown: [ "iptables -D OUTPUT ! -o %i -m mark ! --mark $(wg show %i fwmark) -m addrtype ! --dst-type LOCAL -j REJECT" ], - Address: [ + address: [ "10.144.0.1/32", "192.160.0.1/32", "10.80.0.1/32", "10.48.0.1/32", "10.0.0.1/32", "10.208.0.1/32",