@omindu/yaksha 1.0.1 β 1.0.2
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/package.json +1 -1
- package/src/client/index.js +6 -6
- package/src/core/protocol.js +54 -0
- package/src/server/index.js +7 -7
- package/README.md +0 -597
package/package.json
CHANGED
package/src/client/index.js
CHANGED
|
@@ -251,10 +251,10 @@ class YakshaClient extends EventEmitter {
|
|
|
251
251
|
|
|
252
252
|
const handler = (data) => {
|
|
253
253
|
try {
|
|
254
|
-
const
|
|
254
|
+
const packet = this.protocol.deserialize(data);
|
|
255
255
|
|
|
256
|
-
if (
|
|
257
|
-
const response = JSON.parse(payload.toString('utf8'));
|
|
256
|
+
if (packet.type === Protocol.PACKET_TYPES.HANDSHAKE) {
|
|
257
|
+
const response = JSON.parse(packet.payload.toString('utf8'));
|
|
258
258
|
|
|
259
259
|
// Store session ID
|
|
260
260
|
this.sessionId = response.sessionId;
|
|
@@ -296,15 +296,15 @@ class YakshaClient extends EventEmitter {
|
|
|
296
296
|
this.emit('_rawData', data);
|
|
297
297
|
|
|
298
298
|
try {
|
|
299
|
-
const
|
|
299
|
+
const packet = this.protocol.deserialize(data);
|
|
300
300
|
|
|
301
301
|
this.stats.packetsReceived++;
|
|
302
302
|
this.stats.bytesReceived += data.length;
|
|
303
303
|
|
|
304
304
|
// Handle different packet types
|
|
305
|
-
switch (
|
|
305
|
+
switch (packet.type) {
|
|
306
306
|
case Protocol.PACKET_TYPES.DATA:
|
|
307
|
-
this._handleDataPacket(payload);
|
|
307
|
+
this._handleDataPacket(packet.payload);
|
|
308
308
|
break;
|
|
309
309
|
|
|
310
310
|
case Protocol.PACKET_TYPES.KEEPALIVE:
|
package/src/core/protocol.js
CHANGED
|
@@ -278,6 +278,60 @@ class Protocol {
|
|
|
278
278
|
}
|
|
279
279
|
return `UNKNOWN(${type})`;
|
|
280
280
|
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Create handshake packet
|
|
284
|
+
* @param {number} sessionId - Session identifier
|
|
285
|
+
* @param {number} sequence - Packet sequence number
|
|
286
|
+
* @param {Buffer} payload - Handshake data (usually JSON)
|
|
287
|
+
* @returns {Object} { packet: Buffer, paddingSize: number }
|
|
288
|
+
*/
|
|
289
|
+
createHandshake(sessionId, sequence, payload) {
|
|
290
|
+
return this.serialize(PACKET_TYPES.HANDSHAKE, payload, sessionId, sequence);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Create data packet
|
|
295
|
+
* @param {number} sessionId - Session identifier
|
|
296
|
+
* @param {number} sequence - Packet sequence number
|
|
297
|
+
* @param {Buffer} payload - Data payload
|
|
298
|
+
* @returns {Object} { packet: Buffer, paddingSize: number }
|
|
299
|
+
*/
|
|
300
|
+
createData(sessionId, sequence, payload) {
|
|
301
|
+
return this.serialize(PACKET_TYPES.DATA, payload, sessionId, sequence);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Create ACK packet
|
|
306
|
+
* @param {number} sessionId - Session identifier
|
|
307
|
+
* @param {number} sequence - Packet sequence number
|
|
308
|
+
* @param {Buffer} payload - ACK data (optional)
|
|
309
|
+
* @returns {Object} { packet: Buffer, paddingSize: number }
|
|
310
|
+
*/
|
|
311
|
+
createAck(sessionId, sequence, payload = Buffer.alloc(0)) {
|
|
312
|
+
return this.serialize(PACKET_TYPES.ACK, payload, sessionId, sequence);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Create close packet
|
|
317
|
+
* @param {number} sessionId - Session identifier
|
|
318
|
+
* @param {number} sequence - Packet sequence number
|
|
319
|
+
* @param {Buffer} payload - Close reason (optional)
|
|
320
|
+
* @returns {Object} { packet: Buffer, paddingSize: number }
|
|
321
|
+
*/
|
|
322
|
+
createClose(sessionId, sequence, payload = Buffer.alloc(0)) {
|
|
323
|
+
return this.serialize(PACKET_TYPES.CLOSE, payload, sessionId, sequence);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Create keepalive packet
|
|
328
|
+
* @param {number} sessionId - Session identifier
|
|
329
|
+
* @param {number} sequence - Packet sequence number
|
|
330
|
+
* @returns {Object} { packet: Buffer, paddingSize: number }
|
|
331
|
+
*/
|
|
332
|
+
createKeepalive(sessionId, sequence) {
|
|
333
|
+
return this.serialize(PACKET_TYPES.KEEPALIVE, Buffer.alloc(0), sessionId, sequence);
|
|
334
|
+
}
|
|
281
335
|
}
|
|
282
336
|
|
|
283
337
|
// Export
|
package/src/server/index.js
CHANGED
|
@@ -242,20 +242,20 @@ class YakshaServer extends EventEmitter {
|
|
|
242
242
|
_handleTCPData(buffer, client) {
|
|
243
243
|
try {
|
|
244
244
|
// Parse packet
|
|
245
|
-
const
|
|
245
|
+
const packet = this.protocol.deserialize(buffer);
|
|
246
246
|
|
|
247
247
|
this.stats.packetsReceived++;
|
|
248
|
-
this.stats.bytesReceived +=
|
|
248
|
+
this.stats.bytesReceived += buffer.length;
|
|
249
249
|
client.lastActivity = Date.now();
|
|
250
250
|
|
|
251
251
|
// Handle different packet types
|
|
252
|
-
switch (
|
|
252
|
+
switch (packet.type) {
|
|
253
253
|
case Protocol.PACKET_TYPES.HANDSHAKE:
|
|
254
|
-
this._handleHandshake(payload, client);
|
|
254
|
+
this._handleHandshake(packet.payload, client);
|
|
255
255
|
break;
|
|
256
256
|
|
|
257
257
|
case Protocol.PACKET_TYPES.DATA:
|
|
258
|
-
this._handleData(payload, client);
|
|
258
|
+
this._handleData(packet.payload, client);
|
|
259
259
|
break;
|
|
260
260
|
|
|
261
261
|
case Protocol.PACKET_TYPES.KEEPALIVE:
|
|
@@ -292,14 +292,14 @@ class YakshaServer extends EventEmitter {
|
|
|
292
292
|
}
|
|
293
293
|
|
|
294
294
|
// Process packet
|
|
295
|
-
const
|
|
295
|
+
const packet = this.protocol.deserialize(data);
|
|
296
296
|
|
|
297
297
|
this.stats.packetsReceived++;
|
|
298
298
|
this.stats.bytesReceived += data.length;
|
|
299
299
|
client.lastActivity = Date.now();
|
|
300
300
|
|
|
301
301
|
// Handle data packet
|
|
302
|
-
this._handleData(payload, client, 'udp');
|
|
302
|
+
this._handleData(packet.payload, client, 'udp');
|
|
303
303
|
|
|
304
304
|
} catch (error) {
|
|
305
305
|
this.logger.error('Error processing UDP data:', error.message);
|
package/README.md
DELETED
|
@@ -1,597 +0,0 @@
|
|
|
1
|
-
# Yaksha VPN Protocol
|
|
2
|
-
|
|
3
|
-
<div align="center">
|
|
4
|
-
|
|
5
|
-
β‘οΈ **Lightning-Fast** β’ π **Military-Grade Security** β’ π **Ultra-Lightweight** β’ π‘οΈ **Firewall Bypass**
|
|
6
|
-
|
|
7
|
-
[](https://www.npmjs.com/package/yaksha)
|
|
8
|
-
[](LICENSE)
|
|
9
|
-
[](https://nodejs.org)
|
|
10
|
-
[](https://www.npmjs.com/package/yaksha)
|
|
11
|
-
|
|
12
|
-
A high-performance, lightweight VPN protocol library with advanced firewall bypass capabilities, built for Node.js.
|
|
13
|
-
|
|
14
|
-
[Features](#-features) β’ [Installation](#-installation) β’ [Quick Start](#-quick-start) β’ [Documentation](#-documentation) β’ [Examples](#-examples)
|
|
15
|
-
|
|
16
|
-
</div>
|
|
17
|
-
|
|
18
|
-
---
|
|
19
|
-
|
|
20
|
-
## π― Overview
|
|
21
|
-
|
|
22
|
-
**Yaksha** is a modern VPN protocol implementation designed for maximum performance and security. It combines military-grade encryption with advanced traffic obfuscation techniques to bypass even the most restrictive firewalls and Deep Packet Inspection (DPI) systems.
|
|
23
|
-
|
|
24
|
-
### Why Yaksha?
|
|
25
|
-
|
|
26
|
-
- β‘οΈ **Blazing Fast**: >1 Gbps throughput, <5ms latency overhead
|
|
27
|
-
- πͺΆ **Ultra-Lightweight**: <2000 lines of core code, <50MB memory per 1000 connections
|
|
28
|
-
- π **Military-Grade Security**: AES-256-GCM, ChaCha20-Poly1305, double encryption
|
|
29
|
-
- π‘οΈ **Firewall Bypass**: SNI spoofing, traffic obfuscation, DPI evasion
|
|
30
|
-
- π **DNS Security**: DNS-over-HTTPS, DNS-over-TLS with DNSSEC
|
|
31
|
-
- π¦ **Multi-Path Routing**: Aggregate bandwidth across multiple connections
|
|
32
|
-
- π **TLS Camouflage**: Traffic looks like legitimate HTTPS
|
|
33
|
-
- π¦ **Easy to Use**: Simple API, comprehensive documentation
|
|
34
|
-
- π§ **Highly Configurable**: Four security levels (Low/Medium/High/Custom)
|
|
35
|
-
- π **Cross-Platform**: Pure JavaScript, works everywhere Node.js runs
|
|
36
|
-
|
|
37
|
-
---
|
|
38
|
-
|
|
39
|
-
## β¨ Features
|
|
40
|
-
|
|
41
|
-
### Core Features
|
|
42
|
-
|
|
43
|
-
| Feature | Description |
|
|
44
|
-
|---------|-------------|
|
|
45
|
-
| **Custom Protocol** | Lightweight, efficient protocol optimized for VPN traffic |
|
|
46
|
-
| **Multiple Encryption** | ChaCha20-Poly1305, AES-256-GCM, double encryption |
|
|
47
|
-
| **Perfect Forward Secrecy** | X25519 key exchange with automatic key rotation |
|
|
48
|
-
| **Authentication** | Password, token, and certificate-based auth with 2FA |
|
|
49
|
-
| **TCP + UDP** | Control channel (TCP) + high-speed data channel (UDP) |
|
|
50
|
-
| **Connection Pooling** | Efficient resource management for 10,000+ connections |
|
|
51
|
-
|
|
52
|
-
### Advanced Features
|
|
53
|
-
|
|
54
|
-
| Feature | Description |
|
|
55
|
-
|---------|-------------|
|
|
56
|
-
| **SNI Spoofing** | Replace Server Name Indication with fake domains |
|
|
57
|
-
| **Bug Host Support** | Use specific domains to bypass network restrictions |
|
|
58
|
-
| **Traffic Obfuscation** | Randomize patterns to evade detection |
|
|
59
|
-
| **Multi-Path Routing** | Split traffic across 2-5 simultaneous connections |
|
|
60
|
-
| **DNS Override** | Tunnel all DNS queries through encrypted VPN |
|
|
61
|
-
| **TLS Camouflage** | Mimic TLS 1.3 handshake and traffic patterns |
|
|
62
|
-
| **Firewall Evasion** | Port hopping, packet fragmentation, timing manipulation |
|
|
63
|
-
| **DPI Resistance** | Encrypted payload, randomized structure, protocol masquerading |
|
|
64
|
-
| **Anti-Replay Protection** | Nonce + timestamp validation |
|
|
65
|
-
| **Rate Limiting** | Prevent brute force attacks |
|
|
66
|
-
|
|
67
|
-
### Security Levels
|
|
68
|
-
|
|
69
|
-
#### π’ **LOW** (Speed Priority)
|
|
70
|
-
- **Encryption**: ChaCha20-Poly1305
|
|
71
|
-
- **Throughput**: ~2000 MB/s
|
|
72
|
-
- **Latency**: <2ms overhead
|
|
73
|
-
- **Use Cases**: Streaming, gaming, general browsing
|
|
74
|
-
|
|
75
|
-
#### π‘ **MEDIUM** (Balanced)
|
|
76
|
-
- **Encryption**: AES-256-GCM
|
|
77
|
-
- **Throughput**: ~1000 MB/s
|
|
78
|
-
- **Latency**: <5ms overhead
|
|
79
|
-
- **Use Cases**: Daily use, business applications
|
|
80
|
-
|
|
81
|
-
#### π΄ **HIGH** (Security Priority)
|
|
82
|
-
- **Encryption**: Double (AES-256-GCM + ChaCha20-Poly1305)
|
|
83
|
-
- **Throughput**: ~500 MB/s
|
|
84
|
-
- **Latency**: <10ms overhead
|
|
85
|
-
- **Use Cases**: Banking, sensitive data, high-security environments
|
|
86
|
-
|
|
87
|
-
#### βοΈ **CUSTOM** (User-Defined)
|
|
88
|
-
- **Encryption**: Configurable (ChaCha20, AES-256-GCM, or Double)
|
|
89
|
-
- **Throughput**: Varies based on configuration
|
|
90
|
-
- **Latency**: Varies based on configuration
|
|
91
|
-
- **Use Cases**: Specific requirements, fine-tuned security/performance balance
|
|
92
|
-
- **Flexibility**: Mix and match features from any level
|
|
93
|
-
- **Base Levels**: Start from LOW, MEDIUM, or HIGH and customize
|
|
94
|
-
|
|
95
|
-
**Custom Level Features:**
|
|
96
|
-
```javascript
|
|
97
|
-
// Create custom configuration based on medium level
|
|
98
|
-
const customConfig = SecurityLevels.createCustomConfig({
|
|
99
|
-
encryption: 'double', // Override encryption
|
|
100
|
-
keyExchange: 'x25519-rotate', // Override key exchange
|
|
101
|
-
obfuscation: 'aes-256-gcm', // Override obfuscation
|
|
102
|
-
multiPath: 3, // Custom path count
|
|
103
|
-
keyRotation: true, // Enable key rotation
|
|
104
|
-
keyRotationInterval: 2000 // Custom rotation interval
|
|
105
|
-
}, 'medium'); // Base level
|
|
106
|
-
|
|
107
|
-
// Use with server/client
|
|
108
|
-
const server = createServer({
|
|
109
|
-
securityLevel: 'custom',
|
|
110
|
-
customSecurityConfig: customConfig
|
|
111
|
-
});
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
---
|
|
115
|
-
|
|
116
|
-
## π¦ Installation
|
|
117
|
-
|
|
118
|
-
```bash
|
|
119
|
-
npm install @omindu/yaksha
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
### Requirements
|
|
123
|
-
|
|
124
|
-
- **Node.js**: >=14.0.0
|
|
125
|
-
- **OS**: Windows, Linux, macOS
|
|
126
|
-
- **Dependencies**: `tweetnacl` (automatically installed)
|
|
127
|
-
|
|
128
|
-
---
|
|
129
|
-
|
|
130
|
-
## π Quick Start
|
|
131
|
-
|
|
132
|
-
### Server
|
|
133
|
-
|
|
134
|
-
```javascript
|
|
135
|
-
const yaksha = require('@omindu/yaksha');
|
|
136
|
-
|
|
137
|
-
// Create server
|
|
138
|
-
const server = yaksha.createServer({
|
|
139
|
-
port: 8443,
|
|
140
|
-
securityLevel: 'medium',
|
|
141
|
-
authMethod: 'token'
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
// Register client
|
|
145
|
-
server.auth.registerToken('client1', 'your-secret-token');
|
|
146
|
-
|
|
147
|
-
// Start server
|
|
148
|
-
await server.start();
|
|
149
|
-
console.log('VPN server running on port 8443');
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
### Client
|
|
153
|
-
|
|
154
|
-
```javascript
|
|
155
|
-
const yaksha = require('@omindu/yaksha');
|
|
156
|
-
|
|
157
|
-
// Create client
|
|
158
|
-
const client = yaksha.createClient({
|
|
159
|
-
server: 'vpn.example.com',
|
|
160
|
-
port: 8443,
|
|
161
|
-
securityLevel: 'medium',
|
|
162
|
-
authCredentials: {
|
|
163
|
-
identifier: 'client1',
|
|
164
|
-
token: 'your-secret-token'
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
// Connect
|
|
169
|
-
await client.connect();
|
|
170
|
-
console.log('Connected to VPN server');
|
|
171
|
-
|
|
172
|
-
// Send data
|
|
173
|
-
await client.send(Buffer.from('Hello, VPN!'));
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
### CLI Usage
|
|
177
|
-
|
|
178
|
-
```bash
|
|
179
|
-
# Start server
|
|
180
|
-
yaksha server --port 8443 --security high
|
|
181
|
-
|
|
182
|
-
# Connect client
|
|
183
|
-
yaksha client --server vpn.example.com --token abc123
|
|
184
|
-
|
|
185
|
-
# Generate keys
|
|
186
|
-
yaksha keygen
|
|
187
|
-
|
|
188
|
-
# Run benchmarks
|
|
189
|
-
yaksha benchmark
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
---
|
|
193
|
-
|
|
194
|
-
## π Documentation
|
|
195
|
-
|
|
196
|
-
### Server API
|
|
197
|
-
|
|
198
|
-
```javascript
|
|
199
|
-
const server = yaksha.createServer(options);
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
**Options:**
|
|
203
|
-
- `port` (number): Server port (default: 8443)
|
|
204
|
-
- `host` (string): Bind address (default: '0.0.0.0')
|
|
205
|
-
- `securityLevel` (string): 'low', 'medium', 'high', or 'custom' (default: 'medium')
|
|
206
|
-
- `customSecurityConfig` (object): Custom security configuration (required if securityLevel is 'custom')
|
|
207
|
-
- `authMethod` (string): 'password', 'token', or 'certificate' (default: 'token')
|
|
208
|
-
- `maxConnections` (number): Maximum concurrent connections (default: 10000)
|
|
209
|
-
- `logLevel` (string): 'debug', 'info', 'warn', 'error' (default: 'info')
|
|
210
|
-
|
|
211
|
-
**Methods:**
|
|
212
|
-
- `await server.start()`: Start the server
|
|
213
|
-
- `await server.stop()`: Stop the server
|
|
214
|
-
- `server.sendToClient(sessionId, data, protocol)`: Send data to specific client
|
|
215
|
-
- `server.getStats()`: Get server statistics
|
|
216
|
-
|
|
217
|
-
**Events:**
|
|
218
|
-
- `listening`: Server started
|
|
219
|
-
- `connection`: New client connected
|
|
220
|
-
- `disconnection`: Client disconnected
|
|
221
|
-
- `data`: Data received from client
|
|
222
|
-
- `error`: Error occurred
|
|
223
|
-
|
|
224
|
-
### Client API
|
|
225
|
-
|
|
226
|
-
```javascript
|
|
227
|
-
const client = yaksha.createClient(options);
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
**Options:**
|
|
231
|
-
- `server` (string): Server address (required)
|
|
232
|
-
- `port` (number): Server port (default: 8443)
|
|
233
|
-
- `securityLevel` (string): 'low', 'medium', 'high', or 'custom' (default: 'medium')
|
|
234
|
-
- `customSecurityConfig` (object): Custom security configuration (required if securityLevel is 'custom')
|
|
235
|
-
- `autoReconnect` (boolean): Auto-reconnect on disconnect (default: true)
|
|
236
|
-
- `authCredentials` (object): Authentication credentials
|
|
237
|
-
- `features` (object): Enable/disable features
|
|
238
|
-
|
|
239
|
-
**Methods:**
|
|
240
|
-
- `await client.connect()`: Connect to server
|
|
241
|
-
- `await client.disconnect()`: Disconnect from server
|
|
242
|
-
- `await client.send(data, protocol)`: Send data through VPN
|
|
243
|
-
- `await client.resolveDNS(domain, type)`: Resolve DNS through VPN
|
|
244
|
-
- `client.getStats()`: Get client statistics
|
|
245
|
-
|
|
246
|
-
**Events:**
|
|
247
|
-
- `connected`: Connected to server
|
|
248
|
-
- `disconnected`: Disconnected from server
|
|
249
|
-
- `reconnecting`: Attempting reconnection
|
|
250
|
-
- `data`: Data received from server
|
|
251
|
-
- `error`: Error occurred
|
|
252
|
-
|
|
253
|
-
---
|
|
254
|
-
|
|
255
|
-
## π‘ Examples
|
|
256
|
-
|
|
257
|
-
### Basic Server
|
|
258
|
-
|
|
259
|
-
```javascript
|
|
260
|
-
const yaksha = require('@omindu/yaksha');
|
|
261
|
-
|
|
262
|
-
const server = yaksha.createServer({
|
|
263
|
-
port: 8443,
|
|
264
|
-
securityLevel: 'medium',
|
|
265
|
-
authMethod: 'token'
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
server.auth.registerToken('client1', 'secret-token-123');
|
|
269
|
-
|
|
270
|
-
server.on('connection', (sessionId, address) => {
|
|
271
|
-
console.log(`Client connected: ${address}`);
|
|
272
|
-
});
|
|
273
|
-
|
|
274
|
-
await server.start();
|
|
275
|
-
```
|
|
276
|
-
|
|
277
|
-
### Advanced Configuration
|
|
278
|
-
|
|
279
|
-
```javascript
|
|
280
|
-
const client = yaksha.createClient({
|
|
281
|
-
server: 'vpn.example.com',
|
|
282
|
-
port: 8443,
|
|
283
|
-
securityLevel: 'high',
|
|
284
|
-
features: {
|
|
285
|
-
sniSpoofing: true,
|
|
286
|
-
trafficObfuscation: true,
|
|
287
|
-
multiPath: true,
|
|
288
|
-
dnsOverride: true,
|
|
289
|
-
tlsCamouflage: true,
|
|
290
|
-
firewallEvasion: true
|
|
291
|
-
},
|
|
292
|
-
authCredentials: {
|
|
293
|
-
identifier: 'secure-client',
|
|
294
|
-
certificate: 'base64-cert',
|
|
295
|
-
totpToken: '123456'
|
|
296
|
-
}
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
await client.connect();
|
|
300
|
-
```
|
|
301
|
-
|
|
302
|
-
### Custom Security Level
|
|
303
|
-
|
|
304
|
-
```javascript
|
|
305
|
-
const { createServer, createClient, SecurityLevels } = require('@omindu/yaksha');
|
|
306
|
-
|
|
307
|
-
// Create custom configuration
|
|
308
|
-
const customConfig = SecurityLevels.createCustomConfig({
|
|
309
|
-
encryption: 'double',
|
|
310
|
-
keyExchange: 'x25519-rotate',
|
|
311
|
-
obfuscation: 'aes-256-gcm',
|
|
312
|
-
multiPath: 3,
|
|
313
|
-
keyRotation: true,
|
|
314
|
-
keyRotationInterval: 2000,
|
|
315
|
-
tlsCamouflage: 'full'
|
|
316
|
-
}, 'medium'); // Base level
|
|
317
|
-
|
|
318
|
-
// Server with custom security
|
|
319
|
-
const server = createServer({
|
|
320
|
-
port: 8443,
|
|
321
|
-
securityLevel: 'custom',
|
|
322
|
-
customSecurityConfig: customConfig
|
|
323
|
-
});
|
|
324
|
-
|
|
325
|
-
// Client with custom security
|
|
326
|
-
const client = createClient({
|
|
327
|
-
server: 'localhost',
|
|
328
|
-
port: 8443,
|
|
329
|
-
securityLevel: 'custom',
|
|
330
|
-
customSecurityConfig: customConfig
|
|
331
|
-
});
|
|
332
|
-
```
|
|
333
|
-
|
|
334
|
-
### DNS Resolution
|
|
335
|
-
|
|
336
|
-
```javascript
|
|
337
|
-
const addresses = await client.resolveDNS('example.com', 'A');
|
|
338
|
-
console.log('IP addresses:', addresses);
|
|
339
|
-
```
|
|
340
|
-
|
|
341
|
-
### Bug Host Configuration
|
|
342
|
-
|
|
343
|
-
Bug Host allows bypassing network restrictions by setting SNI to an allowed domain:
|
|
344
|
-
|
|
345
|
-
```javascript
|
|
346
|
-
// Client with bug host
|
|
347
|
-
const client = createClient({
|
|
348
|
-
server: 'vpn.example.com',
|
|
349
|
-
port: 8443,
|
|
350
|
-
bugHost: 'cloudflare.com', // SNI appears as cloudflare.com
|
|
351
|
-
securityLevel: 'custom',
|
|
352
|
-
customSecurityConfig: {
|
|
353
|
-
sniSpoofing: 'static',
|
|
354
|
-
bugHost: 'cloudflare.com'
|
|
355
|
-
}
|
|
356
|
-
});
|
|
357
|
-
|
|
358
|
-
// Popular bug hosts
|
|
359
|
-
const bugHosts = {
|
|
360
|
-
cdn: 'cloudflare.com',
|
|
361
|
-
social: 'facebook.com',
|
|
362
|
-
tech: 'google.com',
|
|
363
|
-
education: 'wikipedia.org'
|
|
364
|
-
};
|
|
365
|
-
```
|
|
366
|
-
|
|
367
|
-
**See [examples/bug-host-example.js](examples/bug-host-example.js) for comprehensive bug host usage.**
|
|
368
|
-
|
|
369
|
-
---
|
|
370
|
-
|
|
371
|
-
## π§ Configuration
|
|
372
|
-
|
|
373
|
-
### Environment Variables
|
|
374
|
-
|
|
375
|
-
```bash
|
|
376
|
-
YAKSHA_HOST=0.0.0.0
|
|
377
|
-
YAKSHA_PORT=8443
|
|
378
|
-
YAKSHA_SECURITY_LEVEL=medium
|
|
379
|
-
YAKSHA_AUTH_METHOD=token
|
|
380
|
-
YAKSHA_LOG_LEVEL=info
|
|
381
|
-
```
|
|
382
|
-
|
|
383
|
-
### Configuration File
|
|
384
|
-
|
|
385
|
-
```json
|
|
386
|
-
{
|
|
387
|
-
"server": {
|
|
388
|
-
"host": "0.0.0.0",
|
|
389
|
-
"port": 8443,
|
|
390
|
-
"maxConnections": 10000
|
|
391
|
-
},
|
|
392
|
-
"security": {
|
|
393
|
-
"level": "high",
|
|
394
|
-
"authMethod": "certificate"
|
|
395
|
-
},
|
|
396
|
-
"features": {
|
|
397
|
-
"sniSpoofing": true,
|
|
398
|
-
"trafficObfuscation": true,
|
|
399
|
-
"multiPath": true,
|
|
400
|
-
"dnsOverride": true,
|
|
401
|
-
"tlsCamouflage": true,
|
|
402
|
-
"firewallEvasion": true
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
```
|
|
406
|
-
|
|
407
|
-
Load with: `const config = new yaksha.Config(); config.loadFromFile('config.json');`
|
|
408
|
-
|
|
409
|
-
---
|
|
410
|
-
|
|
411
|
-
## π Performance
|
|
412
|
-
|
|
413
|
-
### Benchmarks
|
|
414
|
-
|
|
415
|
-
| Metric | Value |
|
|
416
|
-
|--------|-------|
|
|
417
|
-
| Throughput | >1 Gbps on gigabit connection |
|
|
418
|
-
| Latency Overhead | <5ms (medium security) |
|
|
419
|
-
| Memory Usage | <50MB per 1000 connections |
|
|
420
|
-
| CPU Usage | <10% on 4-core modern CPU |
|
|
421
|
-
| Concurrent Connections | 10,000+ |
|
|
422
|
-
| Packet Processing | ~100,000 packets/second |
|
|
423
|
-
|
|
424
|
-
### Optimization Tips
|
|
425
|
-
|
|
426
|
-
1. **Use UDP for data**: Lower latency than TCP
|
|
427
|
-
2. **Enable buffer pooling**: Reduces GC pressure
|
|
428
|
-
3. **Choose appropriate security level**: Balance security vs performance
|
|
429
|
-
4. **Enable multi-path**: Aggregate bandwidth
|
|
430
|
-
5. **Adjust MTU**: Optimize for your network
|
|
431
|
-
|
|
432
|
-
---
|
|
433
|
-
|
|
434
|
-
## π Security
|
|
435
|
-
|
|
436
|
-
### Encryption Algorithms
|
|
437
|
-
|
|
438
|
-
- **ChaCha20-Poly1305**: Fast, secure stream cipher
|
|
439
|
-
- **AES-256-GCM**: Industry standard, hardware-accelerated
|
|
440
|
-
- **Double Encryption**: Maximum security (AES + ChaCha20)
|
|
441
|
-
|
|
442
|
-
### Key Exchange
|
|
443
|
-
|
|
444
|
-
- **X25519**: Elliptic curve Diffie-Hellman
|
|
445
|
-
- **Perfect Forward Secrecy**: New keys for each session
|
|
446
|
-
- **Key Rotation**: Automatic rekeying (high security mode)
|
|
447
|
-
|
|
448
|
-
### Authentication
|
|
449
|
-
|
|
450
|
-
- **Password**: bcrypt hashing, rate limiting
|
|
451
|
-
- **Token**: Time-based, automatic rotation
|
|
452
|
-
- **Certificate**: X.509 with optional 2FA
|
|
453
|
-
|
|
454
|
-
### Security Best Practices
|
|
455
|
-
|
|
456
|
-
1. Always use TLS/SSL in production
|
|
457
|
-
2. Enable all firewall bypass features
|
|
458
|
-
3. Use high security level for sensitive data
|
|
459
|
-
4. Rotate authentication tokens regularly
|
|
460
|
-
5. Use custom security level for specific requirements
|
|
461
|
-
6. Monitor for unusual traffic patterns
|
|
462
|
-
7. Keep dependencies updated
|
|
463
|
-
|
|
464
|
-
### Custom Security Configurations
|
|
465
|
-
|
|
466
|
-
Yaksha supports custom security configurations through the `createCustomConfig` method:
|
|
467
|
-
|
|
468
|
-
```javascript
|
|
469
|
-
const { SecurityLevels } = require('@omindu/yaksha');
|
|
470
|
-
|
|
471
|
-
// IoT Device (Low resource, moderate security)
|
|
472
|
-
const iotConfig = SecurityLevels.createCustomConfig({
|
|
473
|
-
encryption: 'chacha20-poly1305',
|
|
474
|
-
obfuscation: 'xor',
|
|
475
|
-
multiPath: 1,
|
|
476
|
-
keyRotation: false
|
|
477
|
-
}, 'low');
|
|
478
|
-
|
|
479
|
-
// Corporate VPN (Balanced + Compliance)
|
|
480
|
-
const corporateConfig = SecurityLevels.createCustomConfig({
|
|
481
|
-
encryption: 'aes-256-gcm',
|
|
482
|
-
certificateValidation: true,
|
|
483
|
-
keyRotation: true,
|
|
484
|
-
multiPath: 4
|
|
485
|
-
}, 'medium');
|
|
486
|
-
|
|
487
|
-
// Maximum Security (Government/Banking)
|
|
488
|
-
const maxSecurityConfig = SecurityLevels.createCustomConfig({
|
|
489
|
-
encryption: 'double',
|
|
490
|
-
twoFactorAuth: true,
|
|
491
|
-
keyRotationInterval: 250,
|
|
492
|
-
multiPath: 8
|
|
493
|
-
}, 'high');
|
|
494
|
-
```
|
|
495
|
-
|
|
496
|
-
**See [examples/custom-level-example.js](examples/custom-level-example.js) for more custom configurations.**
|
|
497
|
-
|
|
498
|
-
---
|
|
499
|
-
|
|
500
|
-
## π§ͺ Testing
|
|
501
|
-
|
|
502
|
-
```bash
|
|
503
|
-
# Run all tests
|
|
504
|
-
npm test
|
|
505
|
-
|
|
506
|
-
# Run specific test suite
|
|
507
|
-
npm test -- core.test.js
|
|
508
|
-
|
|
509
|
-
# Run with coverage
|
|
510
|
-
npm run test:coverage
|
|
511
|
-
|
|
512
|
-
# Run benchmarks
|
|
513
|
-
npm run benchmark
|
|
514
|
-
```
|
|
515
|
-
|
|
516
|
-
---
|
|
517
|
-
|
|
518
|
-
## π€ Contributing
|
|
519
|
-
|
|
520
|
-
Contributions are welcome! Please read our [Contributing Guidelines](CONTRIBUTING.md) first.
|
|
521
|
-
|
|
522
|
-
1. Fork the repository
|
|
523
|
-
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
|
|
524
|
-
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
|
|
525
|
-
4. Push to the branch (`git push origin feature/AmazingFeature`)
|
|
526
|
-
5. Open a Pull Request
|
|
527
|
-
|
|
528
|
-
---
|
|
529
|
-
|
|
530
|
-
## π License
|
|
531
|
-
|
|
532
|
-
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
533
|
-
|
|
534
|
-
---
|
|
535
|
-
|
|
536
|
-
## π€ Author
|
|
537
|
-
|
|
538
|
-
**Omindu Dissanayaka** (SE U. G)
|
|
539
|
-
|
|
540
|
-
- GitHub: [@OminduDissanayaka](https://github.com/OminduDissanayaka)
|
|
541
|
-
- Email: contact@example.com
|
|
542
|
-
|
|
543
|
-
---
|
|
544
|
-
|
|
545
|
-
## π Acknowledgments
|
|
546
|
-
|
|
547
|
-
- Built with Node.js
|
|
548
|
-
- Uses TweetNaCl for some cryptographic operations
|
|
549
|
-
- Inspired by modern VPN protocols (WireGuard, OpenVPN)
|
|
550
|
-
|
|
551
|
-
---
|
|
552
|
-
|
|
553
|
-
## π Additional Documentation
|
|
554
|
-
|
|
555
|
-
- [API Reference](docs/API.md)
|
|
556
|
-
- [Security Model](docs/SECURITY.md)
|
|
557
|
-
- [Protocol Specification](docs/PROTOCOL.md)
|
|
558
|
-
- [Performance Tuning](docs/PERFORMANCE.md)
|
|
559
|
-
- [Troubleshooting](docs/TROUBLESHOOTING.md)
|
|
560
|
-
|
|
561
|
-
---
|
|
562
|
-
|
|
563
|
-
## πΊοΈ Roadmap
|
|
564
|
-
|
|
565
|
-
### Version 1.1
|
|
566
|
-
- [ ] WebSocket support
|
|
567
|
-
- [ ] QUIC protocol support
|
|
568
|
-
- [ ] IPv6 support
|
|
569
|
-
- [ ] Plugin system
|
|
570
|
-
|
|
571
|
-
### Version 1.2
|
|
572
|
-
- [ ] GUI client
|
|
573
|
-
- [ ] Mobile support (React Native)
|
|
574
|
-
- [ ] Traffic statistics dashboard
|
|
575
|
-
- [ ] Web admin panel
|
|
576
|
-
|
|
577
|
-
### Version 2.0
|
|
578
|
-
- [ ] P2P mode
|
|
579
|
-
- [ ] Mesh networking
|
|
580
|
-
- [ ] Blockchain-based authentication
|
|
581
|
-
- [ ] Quantum-resistant encryption
|
|
582
|
-
|
|
583
|
-
---
|
|
584
|
-
|
|
585
|
-
## β οΈ Disclaimer
|
|
586
|
-
|
|
587
|
-
This software is provided for educational and research purposes. Ensure compliance with local laws and regulations when using VPN technology. The authors are not responsible for misuse of this software.
|
|
588
|
-
|
|
589
|
-
---
|
|
590
|
-
|
|
591
|
-
<div align="center">
|
|
592
|
-
|
|
593
|
-
Made with β€οΈ by Omindu Dissanayaka
|
|
594
|
-
|
|
595
|
-
**If you find this project useful, please give it a βοΈ**
|
|
596
|
-
|
|
597
|
-
</div>
|