wire-vpn 1.0.0 → 1.0.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/binding.gyp +32 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +195 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5 -0
- package/dist/lib/vpn.d.ts +32 -0
- package/dist/lib/vpn.js +149 -0
- package/package/binding.gyp +32 -0
- package/package/build/Makefile +354 -0
- package/package/build/Release/.deps/Release/obj.target/wirevpn/src/addon/vpn.o.d +17 -0
- package/package/build/Release/.deps/Release/obj.target/wirevpn.node.d +1 -0
- package/package/build/Release/.deps/Release/wirevpn.node.d +1 -0
- package/package/build/Release/obj.target/wirevpn/src/addon/vpn.o +0 -0
- package/package/build/Release/obj.target/wirevpn.node +0 -0
- package/package/build/binding.Makefile +6 -0
- package/package/build/wirevpn.target.mk +157 -0
- package/package/dist/cli.d.ts +2 -0
- package/package/dist/cli.js +195 -0
- package/package/dist/index.d.ts +1 -0
- package/package/dist/index.js +5 -0
- package/package/dist/lib/vpn.d.ts +32 -0
- package/package/dist/lib/vpn.js +149 -0
- package/package/package.json +38 -0
- package/package/readme.md +555 -0
- package/package/src/addon/vpn.cc +366 -0
- package/package/src/cli.ts +185 -0
- package/package/src/index.ts +1 -0
- package/package/src/lib/vpn.ts +156 -0
- package/package/tsconfig.json +17 -0
- package/package.json +32 -7
- package/readme.md +555 -0
- package/src/addon/vpn.cc +366 -0
- package/src/cli.ts +185 -0
- package/src/index.ts +1 -0
- package/src/lib/vpn.ts +156 -0
- package/tsconfig.json +17 -0
package/binding.gyp
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"targets": [
|
|
3
|
+
{
|
|
4
|
+
"target_name": "wirevpn",
|
|
5
|
+
"cflags!": [ "-fno-exceptions" ],
|
|
6
|
+
"cflags_cc!": [ "-fno-exceptions" ],
|
|
7
|
+
"include_dirs": [
|
|
8
|
+
"<!@(node -p \"require('node-addon-api').include\")"
|
|
9
|
+
],
|
|
10
|
+
"sources": [
|
|
11
|
+
"src/addon/vpn.cc"
|
|
12
|
+
],
|
|
13
|
+
"defines": [ "NAPI_DISABLE_CPP_EXCEPTIONS" ],
|
|
14
|
+
"libraries": [
|
|
15
|
+
"-lsodium"
|
|
16
|
+
],
|
|
17
|
+
"conditions": [
|
|
18
|
+
["OS=='linux'", {
|
|
19
|
+
"libraries": ["-lsodium"]
|
|
20
|
+
}],
|
|
21
|
+
["OS=='mac'", {
|
|
22
|
+
"xcode_settings": {
|
|
23
|
+
"GCC_ENABLE_CPP_EXCEPTIONS": "YES",
|
|
24
|
+
"CLANG_CXX_LIBRARY": "libc++",
|
|
25
|
+
"MACOSX_DEPLOYMENT_TARGET": "10.15"
|
|
26
|
+
},
|
|
27
|
+
"libraries": ["-lsodium"]
|
|
28
|
+
}]
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
}
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
const commander_1 = require("commander");
|
|
38
|
+
const fs = __importStar(require("fs"));
|
|
39
|
+
const os = __importStar(require("os"));
|
|
40
|
+
const CONFIG_DIR = os.homedir() + '/.vpn';
|
|
41
|
+
const CONFIG_FILE = CONFIG_DIR + '/config.json';
|
|
42
|
+
const KEY_FILE = CONFIG_DIR + '/keys.json';
|
|
43
|
+
function ensureConfigDir() {
|
|
44
|
+
if (!fs.existsSync(CONFIG_DIR)) {
|
|
45
|
+
fs.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function loadConfig() {
|
|
49
|
+
try {
|
|
50
|
+
if (fs.existsSync(CONFIG_FILE)) {
|
|
51
|
+
return JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf-8'));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
catch (e) { }
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
let activeConnection = null;
|
|
58
|
+
commander_1.program
|
|
59
|
+
.name('vpn')
|
|
60
|
+
.description('Native VPN CLI')
|
|
61
|
+
.version('1.0.0');
|
|
62
|
+
commander_1.program
|
|
63
|
+
.command('init')
|
|
64
|
+
.alias('i')
|
|
65
|
+
.description('Generate new private and public keys')
|
|
66
|
+
.action(async () => {
|
|
67
|
+
ensureConfigDir();
|
|
68
|
+
const nativeModule = require('../build/Release/wirevpn.node');
|
|
69
|
+
const crypto = new nativeModule.CryptoEngine();
|
|
70
|
+
const keypair = crypto.generateKeypair();
|
|
71
|
+
const keys = {
|
|
72
|
+
privateKey: keypair.privateKey.toString('hex'),
|
|
73
|
+
publicKey: keypair.publicKey.toString('hex'),
|
|
74
|
+
createdAt: new Date().toISOString()
|
|
75
|
+
};
|
|
76
|
+
fs.writeFileSync(KEY_FILE, JSON.stringify(keys, null, 2));
|
|
77
|
+
console.log('Keys generated successfully!');
|
|
78
|
+
console.log(`Public Key: ${keys.publicKey}`);
|
|
79
|
+
console.log(`Private Key saved to: ${KEY_FILE}`);
|
|
80
|
+
});
|
|
81
|
+
commander_1.program
|
|
82
|
+
.command('up <config>')
|
|
83
|
+
.alias('u')
|
|
84
|
+
.description('Start VPN connection')
|
|
85
|
+
.option('-d, --debug', 'Enable debug mode')
|
|
86
|
+
.action(async (configPath, options) => {
|
|
87
|
+
let config;
|
|
88
|
+
if (fs.existsSync(configPath)) {
|
|
89
|
+
config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
const saved = loadConfig();
|
|
93
|
+
if (saved) {
|
|
94
|
+
config = saved;
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
console.error(`Config file not found: ${configPath}`);
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (fs.existsSync(KEY_FILE)) {
|
|
102
|
+
const keys = JSON.parse(fs.readFileSync(KEY_FILE, 'utf-8'));
|
|
103
|
+
config.privateKey = keys.privateKey;
|
|
104
|
+
config.publicKey = keys.publicKey;
|
|
105
|
+
}
|
|
106
|
+
const { VPNConnection } = require('./lib/vpn');
|
|
107
|
+
activeConnection = new VPNConnection(config, options.debug || false);
|
|
108
|
+
try {
|
|
109
|
+
await activeConnection.init();
|
|
110
|
+
await activeConnection.up();
|
|
111
|
+
console.log('\nVPN is running. Press Ctrl+C to stop.\n');
|
|
112
|
+
const statusInterval = setInterval(() => {
|
|
113
|
+
if (activeConnection) {
|
|
114
|
+
const stats = activeConnection.getStatus();
|
|
115
|
+
const peerList = activeConnection.getPeers();
|
|
116
|
+
process.stdout.write(`\rActive: ${peerList.length} peers | `);
|
|
117
|
+
for (const [key, stat] of Object.entries(stats)) {
|
|
118
|
+
const s = stat;
|
|
119
|
+
process.stdout.write(`TX: ${(s.txBytes / 1024).toFixed(1)}KB RX: ${(s.rxBytes / 1024).toFixed(1)}KB `);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}, 1000);
|
|
123
|
+
process.on('SIGINT', async () => {
|
|
124
|
+
clearInterval(statusInterval);
|
|
125
|
+
if (activeConnection) {
|
|
126
|
+
await activeConnection.down();
|
|
127
|
+
}
|
|
128
|
+
console.log('\nVPN stopped.');
|
|
129
|
+
process.exit(0);
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
catch (err) {
|
|
133
|
+
console.error(`Failed to start VPN: ${err.message}`);
|
|
134
|
+
process.exit(1);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
commander_1.program
|
|
138
|
+
.command('down')
|
|
139
|
+
.alias('d')
|
|
140
|
+
.description('Stop VPN connection')
|
|
141
|
+
.action(async () => {
|
|
142
|
+
if (activeConnection) {
|
|
143
|
+
await activeConnection.down();
|
|
144
|
+
activeConnection = null;
|
|
145
|
+
console.log('VPN connection closed');
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
console.log('No active VPN connection found');
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
commander_1.program
|
|
152
|
+
.command('status')
|
|
153
|
+
.alias('s')
|
|
154
|
+
.description('Display statistics')
|
|
155
|
+
.action(() => {
|
|
156
|
+
if (!activeConnection) {
|
|
157
|
+
console.log('VPN is not running. Use "vpn up" first.');
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
const stats = activeConnection.getStatus();
|
|
161
|
+
if (Object.keys(stats).length === 0) {
|
|
162
|
+
console.log('No active peers');
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
console.log('Peer Statistics:');
|
|
166
|
+
for (const [peer, stat] of Object.entries(stats)) {
|
|
167
|
+
const s = stat;
|
|
168
|
+
console.log(` ${peer.substring(0, 16)}...`);
|
|
169
|
+
console.log(` TX: ${(s.txBytes / 1024).toFixed(2)} KB (${s.txPackets} packets)`);
|
|
170
|
+
console.log(` RX: ${(s.rxBytes / 1024).toFixed(2)} KB (${s.rxPackets} packets)`);
|
|
171
|
+
console.log(` Endpoint: ${s.endpoint}`);
|
|
172
|
+
console.log(` Last seen: ${s.lastSeen}s ago\n`);
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
commander_1.program
|
|
176
|
+
.command('list')
|
|
177
|
+
.alias('l')
|
|
178
|
+
.description('List connected peers')
|
|
179
|
+
.action(() => {
|
|
180
|
+
if (!activeConnection) {
|
|
181
|
+
console.log('VPN is not running. Use "vpn up" first.');
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
const peers = activeConnection.getPeers();
|
|
185
|
+
if (peers.length === 0) {
|
|
186
|
+
console.log('No peers connected');
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
console.log(`Connected peers (${peers.length}):`);
|
|
190
|
+
peers.forEach((peer, idx) => {
|
|
191
|
+
console.log(` ${idx + 1}. ${peer.substring(0, 16)}...`);
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
commander_1.program.parse();
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { VPNConnection, VPNConfig, VPNPeer } from './lib/vpn';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
|
+
export interface VPNPeer {
|
|
3
|
+
publicKey: string;
|
|
4
|
+
endpoint: string;
|
|
5
|
+
allowedIPs: string[];
|
|
6
|
+
}
|
|
7
|
+
export interface VPNConfig {
|
|
8
|
+
privateKey?: string;
|
|
9
|
+
publicKey?: string;
|
|
10
|
+
address: string;
|
|
11
|
+
port: number;
|
|
12
|
+
peers: VPNPeer[];
|
|
13
|
+
mtu?: number;
|
|
14
|
+
}
|
|
15
|
+
export declare class VPNConnection extends EventEmitter {
|
|
16
|
+
private tun;
|
|
17
|
+
private crypto;
|
|
18
|
+
private stats;
|
|
19
|
+
private running;
|
|
20
|
+
private debugMode;
|
|
21
|
+
private udpSocket;
|
|
22
|
+
private config;
|
|
23
|
+
private peerMap;
|
|
24
|
+
private readInterval;
|
|
25
|
+
constructor(config: VPNConfig, debug?: boolean);
|
|
26
|
+
init(): Promise<void>;
|
|
27
|
+
up(): Promise<void>;
|
|
28
|
+
down(): Promise<void>;
|
|
29
|
+
getStatus(): any;
|
|
30
|
+
getPeers(): string[];
|
|
31
|
+
private getPeerKey;
|
|
32
|
+
}
|
package/dist/lib/vpn.js
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.VPNConnection = void 0;
|
|
37
|
+
const events_1 = require("events");
|
|
38
|
+
const dgram = __importStar(require("dgram"));
|
|
39
|
+
const nativeModule = require('../../build/Release/wirevpn.node');
|
|
40
|
+
class VPNConnection extends events_1.EventEmitter {
|
|
41
|
+
constructor(config, debug = false) {
|
|
42
|
+
super();
|
|
43
|
+
this.running = false;
|
|
44
|
+
this.debugMode = false;
|
|
45
|
+
this.readInterval = null;
|
|
46
|
+
this.config = config;
|
|
47
|
+
this.debugMode = debug;
|
|
48
|
+
this.tun = new nativeModule.TunDevice();
|
|
49
|
+
this.crypto = new nativeModule.CryptoEngine();
|
|
50
|
+
this.stats = nativeModule.StatsCollector;
|
|
51
|
+
this.peerMap = new Map();
|
|
52
|
+
this.udpSocket = null;
|
|
53
|
+
}
|
|
54
|
+
async init() {
|
|
55
|
+
let privateKey = this.config.privateKey;
|
|
56
|
+
if (!privateKey) {
|
|
57
|
+
const keypair = this.crypto.generateKeypair();
|
|
58
|
+
privateKey = keypair.privateKey.toString('hex');
|
|
59
|
+
this.config.privateKey = privateKey;
|
|
60
|
+
this.config.publicKey = keypair.publicKey.toString('hex');
|
|
61
|
+
console.log(`Generated new keypair - Public: ${this.config.publicKey}`);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
this.crypto.setPrivateKey(Buffer.from(privateKey, 'hex'));
|
|
65
|
+
}
|
|
66
|
+
for (const peer of this.config.peers) {
|
|
67
|
+
this.crypto.setPeerPublicKey(Buffer.from(peer.publicKey, 'hex'));
|
|
68
|
+
this.peerMap.set(peer.publicKey, peer);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
async up() {
|
|
72
|
+
const tunFd = this.tun.open();
|
|
73
|
+
if (tunFd < 0) {
|
|
74
|
+
throw new Error('Failed to open TUN device');
|
|
75
|
+
}
|
|
76
|
+
this.tun.configure(this.config.address, this.config.mtu || 1500);
|
|
77
|
+
this.udpSocket = dgram.createSocket('udp4');
|
|
78
|
+
await new Promise((resolve) => {
|
|
79
|
+
this.udpSocket.bind(this.config.port, () => resolve());
|
|
80
|
+
});
|
|
81
|
+
this.running = true;
|
|
82
|
+
this.udpSocket.on('message', (data, rinfo) => {
|
|
83
|
+
const decrypted = this.crypto.decrypt(data);
|
|
84
|
+
if (decrypted && decrypted.length > 0) {
|
|
85
|
+
const peerKey = this.getPeerKey(rinfo.address, rinfo.port);
|
|
86
|
+
if (this.stats && this.stats.recordRx) {
|
|
87
|
+
this.stats.recordRx(peerKey, decrypted.length, `${rinfo.address}:${rinfo.port}`);
|
|
88
|
+
}
|
|
89
|
+
this.tun.write(decrypted);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
this.readInterval = setInterval(() => {
|
|
93
|
+
if (!this.running)
|
|
94
|
+
return;
|
|
95
|
+
const packet = this.tun.read();
|
|
96
|
+
if (packet && packet.length > 0) {
|
|
97
|
+
if (this.debugMode) {
|
|
98
|
+
const hexdump = this.tun.getHexDump(packet);
|
|
99
|
+
console.log(`[DEBUG] TUN packet (${packet.length} bytes):\n${hexdump}`);
|
|
100
|
+
}
|
|
101
|
+
const encrypted = this.crypto.encrypt(packet);
|
|
102
|
+
if (encrypted && encrypted.length > 0) {
|
|
103
|
+
for (const peer of this.peerMap.values()) {
|
|
104
|
+
const [host, port] = peer.endpoint.split(':');
|
|
105
|
+
this.udpSocket.send(encrypted, parseInt(port), host);
|
|
106
|
+
if (this.stats && this.stats.recordTx) {
|
|
107
|
+
this.stats.recordTx(peer.publicKey, encrypted.length, peer.endpoint);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}, 10);
|
|
113
|
+
console.log(`VPN UP - Interface: ${this.tun.name}, IP: ${this.config.address}, Port: ${this.config.port}`);
|
|
114
|
+
}
|
|
115
|
+
async down() {
|
|
116
|
+
this.running = false;
|
|
117
|
+
if (this.readInterval) {
|
|
118
|
+
clearInterval(this.readInterval);
|
|
119
|
+
this.readInterval = null;
|
|
120
|
+
}
|
|
121
|
+
if (this.udpSocket) {
|
|
122
|
+
this.udpSocket.close();
|
|
123
|
+
this.udpSocket = null;
|
|
124
|
+
}
|
|
125
|
+
this.tun.close();
|
|
126
|
+
console.log('VPN DOWN - Interface closed');
|
|
127
|
+
}
|
|
128
|
+
getStatus() {
|
|
129
|
+
if (this.stats && this.stats.getStats) {
|
|
130
|
+
return this.stats.getStats();
|
|
131
|
+
}
|
|
132
|
+
return {};
|
|
133
|
+
}
|
|
134
|
+
getPeers() {
|
|
135
|
+
if (this.stats && this.stats.getAllPeers) {
|
|
136
|
+
return this.stats.getAllPeers();
|
|
137
|
+
}
|
|
138
|
+
return [];
|
|
139
|
+
}
|
|
140
|
+
getPeerKey(ip, port) {
|
|
141
|
+
for (const [key, peer] of this.peerMap.entries()) {
|
|
142
|
+
if (peer.endpoint === `${ip}:${port}`) {
|
|
143
|
+
return key;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return `${ip}:${port}`;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
exports.VPNConnection = VPNConnection;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"targets": [
|
|
3
|
+
{
|
|
4
|
+
"target_name": "wirevpn",
|
|
5
|
+
"cflags!": [ "-fno-exceptions" ],
|
|
6
|
+
"cflags_cc!": [ "-fno-exceptions" ],
|
|
7
|
+
"include_dirs": [
|
|
8
|
+
"<!@(node -p \"require('node-addon-api').include\")"
|
|
9
|
+
],
|
|
10
|
+
"sources": [
|
|
11
|
+
"src/addon/vpn.cc"
|
|
12
|
+
],
|
|
13
|
+
"defines": [ "NAPI_DISABLE_CPP_EXCEPTIONS" ],
|
|
14
|
+
"libraries": [
|
|
15
|
+
"-lsodium"
|
|
16
|
+
],
|
|
17
|
+
"conditions": [
|
|
18
|
+
["OS=='linux'", {
|
|
19
|
+
"libraries": ["-lsodium"]
|
|
20
|
+
}],
|
|
21
|
+
["OS=='mac'", {
|
|
22
|
+
"xcode_settings": {
|
|
23
|
+
"GCC_ENABLE_CPP_EXCEPTIONS": "YES",
|
|
24
|
+
"CLANG_CXX_LIBRARY": "libc++",
|
|
25
|
+
"MACOSX_DEPLOYMENT_TARGET": "10.15"
|
|
26
|
+
},
|
|
27
|
+
"libraries": ["-lsodium"]
|
|
28
|
+
}]
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
}
|