@push.rocks/smartproxy 21.1.7 → 22.4.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/changelog.md +81 -0
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/core/utils/shared-security-manager.d.ts +17 -0
- package/dist_ts/core/utils/shared-security-manager.js +66 -1
- package/dist_ts/proxies/http-proxy/default-certificates.d.ts +54 -0
- package/dist_ts/proxies/http-proxy/default-certificates.js +127 -0
- package/dist_ts/proxies/http-proxy/http-proxy.d.ts +1 -1
- package/dist_ts/proxies/http-proxy/http-proxy.js +9 -14
- package/dist_ts/proxies/http-proxy/index.d.ts +5 -1
- package/dist_ts/proxies/http-proxy/index.js +6 -2
- package/dist_ts/proxies/http-proxy/security-manager.d.ts +4 -12
- package/dist_ts/proxies/http-proxy/security-manager.js +66 -99
- package/dist_ts/proxies/nftables-proxy/index.d.ts +1 -0
- package/dist_ts/proxies/nftables-proxy/index.js +2 -1
- package/dist_ts/proxies/nftables-proxy/nftables-proxy.d.ts +4 -26
- package/dist_ts/proxies/nftables-proxy/nftables-proxy.js +84 -236
- package/dist_ts/proxies/nftables-proxy/utils/index.d.ts +9 -0
- package/dist_ts/proxies/nftables-proxy/utils/index.js +12 -0
- package/dist_ts/proxies/nftables-proxy/utils/nft-command-executor.d.ts +66 -0
- package/dist_ts/proxies/nftables-proxy/utils/nft-command-executor.js +131 -0
- package/dist_ts/proxies/nftables-proxy/utils/nft-port-spec-normalizer.d.ts +39 -0
- package/dist_ts/proxies/nftables-proxy/utils/nft-port-spec-normalizer.js +112 -0
- package/dist_ts/proxies/nftables-proxy/utils/nft-rule-validator.d.ts +59 -0
- package/dist_ts/proxies/nftables-proxy/utils/nft-rule-validator.js +130 -0
- package/dist_ts/proxies/smart-proxy/certificate-manager.js +4 -3
- package/dist_ts/proxies/smart-proxy/connection-manager.d.ts +13 -2
- package/dist_ts/proxies/smart-proxy/connection-manager.js +16 -6
- package/dist_ts/proxies/smart-proxy/http-proxy-bridge.js +35 -10
- package/dist_ts/proxies/smart-proxy/models/interfaces.d.ts +0 -1
- package/dist_ts/proxies/smart-proxy/route-connection-handler.d.ts +17 -0
- package/dist_ts/proxies/smart-proxy/route-connection-handler.js +72 -9
- package/dist_ts/proxies/smart-proxy/security-manager.d.ts +14 -12
- package/dist_ts/proxies/smart-proxy/security-manager.js +80 -74
- package/dist_ts/proxies/smart-proxy/smart-proxy.js +1 -2
- package/dist_ts/proxies/smart-proxy/tls-manager.d.ts +2 -9
- package/dist_ts/proxies/smart-proxy/tls-manager.js +3 -26
- package/dist_ts/proxies/smart-proxy/utils/index.d.ts +1 -1
- package/dist_ts/proxies/smart-proxy/utils/index.js +3 -4
- package/dist_ts/proxies/smart-proxy/utils/route-helpers/api-helpers.d.ts +49 -0
- package/dist_ts/proxies/smart-proxy/utils/route-helpers/api-helpers.js +108 -0
- package/dist_ts/proxies/smart-proxy/utils/route-helpers/dynamic-helpers.d.ts +57 -0
- package/dist_ts/proxies/smart-proxy/utils/route-helpers/dynamic-helpers.js +89 -0
- package/dist_ts/proxies/smart-proxy/utils/route-helpers/http-helpers.d.ts +17 -0
- package/dist_ts/proxies/smart-proxy/utils/route-helpers/http-helpers.js +32 -0
- package/dist_ts/proxies/smart-proxy/utils/route-helpers/https-helpers.d.ts +68 -0
- package/dist_ts/proxies/smart-proxy/utils/route-helpers/https-helpers.js +117 -0
- package/dist_ts/proxies/smart-proxy/utils/route-helpers/index.d.ts +17 -0
- package/dist_ts/proxies/smart-proxy/utils/route-helpers/index.js +27 -0
- package/dist_ts/proxies/smart-proxy/utils/route-helpers/load-balancer-helpers.d.ts +63 -0
- package/dist_ts/proxies/smart-proxy/utils/route-helpers/load-balancer-helpers.js +105 -0
- package/dist_ts/proxies/smart-proxy/utils/route-helpers/nftables-helpers.d.ts +83 -0
- package/dist_ts/proxies/smart-proxy/utils/route-helpers/nftables-helpers.js +126 -0
- package/dist_ts/proxies/smart-proxy/utils/route-helpers/security-helpers.d.ts +47 -0
- package/dist_ts/proxies/smart-proxy/utils/route-helpers/security-helpers.js +66 -0
- package/dist_ts/proxies/smart-proxy/utils/route-helpers/socket-handlers.d.ts +70 -0
- package/dist_ts/proxies/smart-proxy/utils/route-helpers/socket-handlers.js +287 -0
- package/dist_ts/proxies/smart-proxy/utils/route-helpers/websocket-helpers.d.ts +46 -0
- package/dist_ts/proxies/smart-proxy/utils/route-helpers/websocket-helpers.js +67 -0
- package/dist_ts/proxies/smart-proxy/utils/route-helpers.d.ts +4 -457
- package/dist_ts/proxies/smart-proxy/utils/route-helpers.js +6 -950
- package/dist_ts/proxies/smart-proxy/utils/route-utils.js +2 -2
- package/dist_ts/proxies/smart-proxy/utils/route-validator.d.ts +67 -1
- package/dist_ts/proxies/smart-proxy/utils/route-validator.js +251 -3
- package/npmextra.json +12 -6
- package/package.json +34 -24
- package/readme.hints.md +184 -1
- package/readme.md +235 -172
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/core/utils/shared-security-manager.ts +98 -13
- package/ts/proxies/http-proxy/default-certificates.ts +150 -0
- package/ts/proxies/http-proxy/http-proxy.ts +9 -15
- package/ts/proxies/http-proxy/index.ts +6 -1
- package/ts/proxies/http-proxy/security-manager.ts +141 -161
- package/ts/proxies/nftables-proxy/index.ts +1 -0
- package/ts/proxies/nftables-proxy/nftables-proxy.ts +116 -290
- package/ts/proxies/nftables-proxy/utils/index.ts +38 -0
- package/ts/proxies/nftables-proxy/utils/nft-command-executor.ts +162 -0
- package/ts/proxies/nftables-proxy/utils/nft-port-spec-normalizer.ts +125 -0
- package/ts/proxies/nftables-proxy/utils/nft-rule-validator.ts +156 -0
- package/ts/proxies/smart-proxy/certificate-manager.ts +3 -2
- package/ts/proxies/smart-proxy/connection-manager.ts +21 -8
- package/ts/proxies/smart-proxy/http-proxy-bridge.ts +39 -13
- package/ts/proxies/smart-proxy/models/interfaces.ts +0 -1
- package/ts/proxies/smart-proxy/route-connection-handler.ts +88 -16
- package/ts/proxies/smart-proxy/security-manager.ts +98 -86
- package/ts/proxies/smart-proxy/smart-proxy.ts +0 -2
- package/ts/proxies/smart-proxy/tls-manager.ts +1 -37
- package/ts/proxies/smart-proxy/utils/index.ts +3 -5
- package/ts/proxies/smart-proxy/utils/route-helpers/api-helpers.ts +144 -0
- package/ts/proxies/smart-proxy/utils/route-helpers/dynamic-helpers.ts +124 -0
- package/ts/proxies/smart-proxy/utils/route-helpers/http-helpers.ts +40 -0
- package/ts/proxies/smart-proxy/utils/route-helpers/https-helpers.ts +163 -0
- package/ts/proxies/smart-proxy/utils/route-helpers/index.ts +62 -0
- package/ts/proxies/smart-proxy/utils/route-helpers/load-balancer-helpers.ts +154 -0
- package/ts/proxies/smart-proxy/utils/route-helpers/nftables-helpers.ts +202 -0
- package/ts/proxies/smart-proxy/utils/route-helpers/security-helpers.ts +96 -0
- package/ts/proxies/smart-proxy/utils/route-helpers/socket-handlers.ts +337 -0
- package/ts/proxies/smart-proxy/utils/route-helpers/websocket-helpers.ts +98 -0
- package/ts/proxies/smart-proxy/utils/route-helpers.ts +5 -1302
- package/ts/proxies/smart-proxy/utils/route-utils.ts +1 -1
- package/ts/proxies/smart-proxy/utils/route-validator.ts +274 -4
- package/ts/proxies/http-proxy/certificate-manager.ts +0 -244
- package/ts/proxies/smart-proxy/utils/route-validators.ts +0 -283
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebSocket Route Helper Functions
|
|
3
|
+
*
|
|
4
|
+
* This module provides utility functions for creating WebSocket route configurations.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { IRouteConfig, IRouteMatch, IRouteAction } from '../../models/route-types.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Create a WebSocket route configuration
|
|
11
|
+
* @param domains Domain(s) to match
|
|
12
|
+
* @param targetOrPath Target server OR WebSocket path (legacy)
|
|
13
|
+
* @param targetOrOptions Target server (legacy) OR options
|
|
14
|
+
* @param options Additional route options (legacy)
|
|
15
|
+
* @returns Route configuration object
|
|
16
|
+
*/
|
|
17
|
+
export function createWebSocketRoute(
|
|
18
|
+
domains: string | string[],
|
|
19
|
+
targetOrPath: { host: string | string[]; port: number } | string,
|
|
20
|
+
targetOrOptions?: { host: string | string[]; port: number } | {
|
|
21
|
+
useTls?: boolean;
|
|
22
|
+
certificate?: 'auto' | { key: string; cert: string };
|
|
23
|
+
path?: string;
|
|
24
|
+
httpPort?: number | number[];
|
|
25
|
+
httpsPort?: number | number[];
|
|
26
|
+
pingInterval?: number;
|
|
27
|
+
pingTimeout?: number;
|
|
28
|
+
name?: string;
|
|
29
|
+
[key: string]: any;
|
|
30
|
+
},
|
|
31
|
+
options?: {
|
|
32
|
+
useTls?: boolean;
|
|
33
|
+
certificate?: 'auto' | { key: string; cert: string };
|
|
34
|
+
httpPort?: number | number[];
|
|
35
|
+
httpsPort?: number | number[];
|
|
36
|
+
pingInterval?: number;
|
|
37
|
+
pingTimeout?: number;
|
|
38
|
+
name?: string;
|
|
39
|
+
[key: string]: any;
|
|
40
|
+
}
|
|
41
|
+
): IRouteConfig {
|
|
42
|
+
// Handle different signatures
|
|
43
|
+
let target: { host: string | string[]; port: number };
|
|
44
|
+
let wsPath: string;
|
|
45
|
+
let finalOptions: any;
|
|
46
|
+
|
|
47
|
+
if (typeof targetOrPath === 'string') {
|
|
48
|
+
// Legacy signature: (domains, path, target, options)
|
|
49
|
+
wsPath = targetOrPath;
|
|
50
|
+
target = targetOrOptions as { host: string | string[]; port: number };
|
|
51
|
+
finalOptions = options || {};
|
|
52
|
+
} else {
|
|
53
|
+
// New signature: (domains, target, options)
|
|
54
|
+
target = targetOrPath;
|
|
55
|
+
finalOptions = (targetOrOptions as any) || {};
|
|
56
|
+
wsPath = finalOptions.path || '/ws';
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Normalize WebSocket path
|
|
60
|
+
const normalizedPath = wsPath.startsWith('/') ? wsPath : `/${wsPath}`;
|
|
61
|
+
|
|
62
|
+
// Create route match
|
|
63
|
+
const match: IRouteMatch = {
|
|
64
|
+
ports: finalOptions.useTls
|
|
65
|
+
? (finalOptions.httpsPort || 443)
|
|
66
|
+
: (finalOptions.httpPort || 80),
|
|
67
|
+
domains,
|
|
68
|
+
path: normalizedPath
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// Create route action
|
|
72
|
+
const action: IRouteAction = {
|
|
73
|
+
type: 'forward',
|
|
74
|
+
targets: [target],
|
|
75
|
+
websocket: {
|
|
76
|
+
enabled: true,
|
|
77
|
+
pingInterval: finalOptions.pingInterval || 30000, // 30 seconds
|
|
78
|
+
pingTimeout: finalOptions.pingTimeout || 5000 // 5 seconds
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
// Add TLS configuration if using HTTPS
|
|
83
|
+
if (finalOptions.useTls) {
|
|
84
|
+
action.tls = {
|
|
85
|
+
mode: 'terminate',
|
|
86
|
+
certificate: finalOptions.certificate || 'auto'
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Create the route config
|
|
91
|
+
return {
|
|
92
|
+
match,
|
|
93
|
+
action,
|
|
94
|
+
name: finalOptions.name || `WebSocket Route ${normalizedPath} for ${Array.isArray(domains) ? domains.join(', ') : domains}`,
|
|
95
|
+
priority: finalOptions.priority || 100, // Higher priority for WebSocket routes
|
|
96
|
+
...finalOptions
|
|
97
|
+
};
|
|
98
|
+
}
|