dvpn-core 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -0
- package/bin/dvpn.js +41 -0
- package/package.json +38 -0
- package/scripts/build-binaries.js +59 -0
- package/scripts/doctor.js +33 -0
- package/vendor/dvpn-linux-amd64 +0 -0
- package/vendor/dvpn-linux-arm64 +0 -0
- package/vendor/dvpn-windows-amd64.exe +0 -0
- package/vendor/dvpn-windows-arm64.exe +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# dvpn-core
|
|
2
|
+
|
|
3
|
+
Node/npm distribution package for the DVPN Core CLI.
|
|
4
|
+
|
|
5
|
+
The npm package exposes a single command:
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
dvpn
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Supported package targets:
|
|
12
|
+
|
|
13
|
+
- Linux x64
|
|
14
|
+
- Linux arm64
|
|
15
|
+
- Windows x64
|
|
16
|
+
- Windows arm64
|
|
17
|
+
|
|
18
|
+
## Install From A Packed Build
|
|
19
|
+
|
|
20
|
+
From the repository root:
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
cd packages/npm
|
|
24
|
+
npm pack
|
|
25
|
+
npm install -g dvpn-core-0.1.0.tgz
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Commands
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
dvpn client relays
|
|
32
|
+
dvpn client connect
|
|
33
|
+
dvpn client disconnect
|
|
34
|
+
dvpn client status
|
|
35
|
+
dvpn node run
|
|
36
|
+
dvpn control run
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Platform Notes
|
|
40
|
+
|
|
41
|
+
The npm package distributes the DVPN CLI binary. Real VPN tunnel activation also
|
|
42
|
+
requires native WireGuard support:
|
|
43
|
+
|
|
44
|
+
- Linux: `wg`, `wg-quick`, route/firewall tools, and root privileges.
|
|
45
|
+
- Windows: WireGuard for Windows or a future `wireguard-nt` integration.
|
package/bin/dvpn.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { spawnSync } = require("node:child_process");
|
|
4
|
+
const path = require("node:path");
|
|
5
|
+
|
|
6
|
+
const platformMap = {
|
|
7
|
+
linux: "linux",
|
|
8
|
+
win32: "windows",
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const archMap = {
|
|
12
|
+
x64: "amd64",
|
|
13
|
+
arm64: "arm64",
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
function binaryName() {
|
|
17
|
+
const platform = platformMap[process.platform];
|
|
18
|
+
const arch = archMap[process.arch];
|
|
19
|
+
if (!platform || !arch) {
|
|
20
|
+
throw new Error(`Unsupported platform: ${process.platform}/${process.arch}`);
|
|
21
|
+
}
|
|
22
|
+
return `dvpn-${platform}-${arch}${platform === "windows" ? ".exe" : ""}`;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function resolveBinary() {
|
|
26
|
+
if (process.env.DVPN_BIN) {
|
|
27
|
+
return process.env.DVPN_BIN;
|
|
28
|
+
}
|
|
29
|
+
return path.join(__dirname, "..", "vendor", binaryName());
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const bin = resolveBinary();
|
|
33
|
+
const result = spawnSync(bin, process.argv.slice(2), { stdio: "inherit" });
|
|
34
|
+
|
|
35
|
+
if (result.error) {
|
|
36
|
+
console.error(`Failed to execute ${bin}: ${result.error.message}`);
|
|
37
|
+
console.error("Run `npm run build:go` from packages/npm or install a package that includes platform binaries.");
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
process.exit(result.status ?? 1);
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "dvpn-core",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "DVPN Core CLI for clients, relay nodes, and control plane operators.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"bin": {
|
|
7
|
+
"dvpn": "bin/dvpn.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin",
|
|
11
|
+
"scripts",
|
|
12
|
+
"vendor",
|
|
13
|
+
"README.md"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build:go": "node scripts/build-binaries.js",
|
|
17
|
+
"prepack": "npm run build:go",
|
|
18
|
+
"doctor": "node scripts/doctor.js"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"dvpn",
|
|
22
|
+
"vpn",
|
|
23
|
+
"wireguard",
|
|
24
|
+
"privacy",
|
|
25
|
+
"depin"
|
|
26
|
+
],
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=18"
|
|
29
|
+
},
|
|
30
|
+
"os": [
|
|
31
|
+
"linux",
|
|
32
|
+
"win32"
|
|
33
|
+
],
|
|
34
|
+
"cpu": [
|
|
35
|
+
"x64",
|
|
36
|
+
"arm64"
|
|
37
|
+
]
|
|
38
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { spawnSync } = require("node:child_process");
|
|
4
|
+
const fs = require("node:fs");
|
|
5
|
+
const path = require("node:path");
|
|
6
|
+
|
|
7
|
+
const packageRoot = path.resolve(__dirname, "..");
|
|
8
|
+
const repoRoot = path.resolve(packageRoot, "..", "..");
|
|
9
|
+
const vendorDir = path.join(packageRoot, "vendor");
|
|
10
|
+
const pkg = require(path.join(packageRoot, "package.json"));
|
|
11
|
+
|
|
12
|
+
function gitValue(args, fallback) {
|
|
13
|
+
const result = spawnSync("git", args, { cwd: repoRoot, encoding: "utf8" });
|
|
14
|
+
if (result.status !== 0) return fallback;
|
|
15
|
+
return result.stdout.trim() || fallback;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const version = process.env.DVPN_VERSION || `v${pkg.version}`;
|
|
19
|
+
const commit = process.env.DVPN_COMMIT || gitValue(["rev-parse", "--short", "HEAD"], "unknown");
|
|
20
|
+
const date = process.env.DVPN_BUILD_DATE || new Date().toISOString();
|
|
21
|
+
const ldflags = [
|
|
22
|
+
"-s",
|
|
23
|
+
"-w",
|
|
24
|
+
`-X main.version=${version}`,
|
|
25
|
+
`-X main.commit=${commit}`,
|
|
26
|
+
`-X main.date=${date}`,
|
|
27
|
+
].join(" ");
|
|
28
|
+
|
|
29
|
+
const targets = [
|
|
30
|
+
{ goos: "linux", goarch: "amd64", name: "dvpn-linux-amd64" },
|
|
31
|
+
{ goos: "linux", goarch: "arm64", name: "dvpn-linux-arm64" },
|
|
32
|
+
{ goos: "windows", goarch: "amd64", name: "dvpn-windows-amd64.exe" },
|
|
33
|
+
{ goos: "windows", goarch: "arm64", name: "dvpn-windows-arm64.exe" },
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
fs.mkdirSync(vendorDir, { recursive: true });
|
|
37
|
+
|
|
38
|
+
for (const target of targets) {
|
|
39
|
+
const out = path.join(vendorDir, target.name);
|
|
40
|
+
const env = {
|
|
41
|
+
...process.env,
|
|
42
|
+
CGO_ENABLED: "0",
|
|
43
|
+
GOOS: target.goos,
|
|
44
|
+
GOARCH: target.goarch,
|
|
45
|
+
};
|
|
46
|
+
const result = spawnSync("go", ["build", "-trimpath", `-ldflags=${ldflags}`, "-o", out, "./cmd/dvpn"], {
|
|
47
|
+
cwd: repoRoot,
|
|
48
|
+
env,
|
|
49
|
+
stdio: "inherit",
|
|
50
|
+
});
|
|
51
|
+
if (result.status !== 0) {
|
|
52
|
+
process.exit(result.status ?? 1);
|
|
53
|
+
}
|
|
54
|
+
if (target.goos !== "windows") {
|
|
55
|
+
fs.chmodSync(out, 0o755);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
console.log(`Built ${targets.length} DVPN binaries in ${vendorDir}`);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { spawnSync } = require("node:child_process");
|
|
4
|
+
|
|
5
|
+
const checks = [["dvpn binary", process.execPath, [require.resolve("../bin/dvpn.js"), "--version"], true]];
|
|
6
|
+
|
|
7
|
+
if (process.platform === "linux") {
|
|
8
|
+
checks.push(
|
|
9
|
+
["wg", "wg", ["--version"], false],
|
|
10
|
+
["wg-quick", "wg-quick", ["--version"], false],
|
|
11
|
+
["ip", "ip", ["-Version"], false],
|
|
12
|
+
);
|
|
13
|
+
} else if (process.platform === "win32") {
|
|
14
|
+
checks.push(["wireguard.exe", "wireguard.exe", ["/installtunnelservice"], false]);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
let failed = false;
|
|
18
|
+
|
|
19
|
+
for (const [label, command, args, required] of checks) {
|
|
20
|
+
const result = spawnSync(command, args, { encoding: "utf8" });
|
|
21
|
+
if (result.status === 0) {
|
|
22
|
+
console.log(`[ok] ${label}`);
|
|
23
|
+
} else {
|
|
24
|
+
failed = failed || required;
|
|
25
|
+
console.log(`[missing] ${label}${required ? "" : " (required for tunnel activation)"}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (process.platform === "win32") {
|
|
30
|
+
console.log("Windows tunnel activation requires WireGuard for Windows or a future wireguard-nt integration.");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
process.exit(failed ? 1 : 0);
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|