@push.rocks/smartproxy 15.0.2 → 16.0.3
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/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/certificate/index.d.ts +10 -4
- package/dist_ts/certificate/index.js +5 -7
- package/dist_ts/certificate/models/certificate-types.d.ts +35 -15
- package/dist_ts/certificate/providers/cert-provisioner.d.ts +41 -15
- package/dist_ts/certificate/providers/cert-provisioner.js +201 -41
- package/dist_ts/core/models/index.d.ts +2 -0
- package/dist_ts/core/models/index.js +3 -1
- package/dist_ts/core/models/route-context.d.ts +62 -0
- package/dist_ts/core/models/route-context.js +43 -0
- package/dist_ts/core/models/socket-augmentation.d.ts +12 -0
- package/dist_ts/core/models/socket-augmentation.js +18 -0
- package/dist_ts/core/utils/event-system.d.ts +200 -0
- package/dist_ts/core/utils/event-system.js +224 -0
- package/dist_ts/core/utils/index.d.ts +7 -0
- package/dist_ts/core/utils/index.js +8 -1
- package/dist_ts/core/utils/route-manager.d.ts +118 -0
- package/dist_ts/core/utils/route-manager.js +383 -0
- package/dist_ts/core/utils/route-utils.d.ts +94 -0
- package/dist_ts/core/utils/route-utils.js +264 -0
- package/dist_ts/core/utils/security-utils.d.ts +111 -0
- package/dist_ts/core/utils/security-utils.js +212 -0
- package/dist_ts/core/utils/shared-security-manager.d.ts +110 -0
- package/dist_ts/core/utils/shared-security-manager.js +252 -0
- package/dist_ts/core/utils/template-utils.d.ts +37 -0
- package/dist_ts/core/utils/template-utils.js +104 -0
- package/dist_ts/core/utils/websocket-utils.d.ts +23 -0
- package/dist_ts/core/utils/websocket-utils.js +86 -0
- package/dist_ts/forwarding/config/forwarding-types.d.ts +40 -76
- package/dist_ts/forwarding/config/forwarding-types.js +19 -18
- package/dist_ts/forwarding/config/index.d.ts +4 -2
- package/dist_ts/forwarding/config/index.js +5 -3
- package/dist_ts/forwarding/handlers/base-handler.js +3 -1
- package/dist_ts/forwarding/index.d.ts +5 -6
- package/dist_ts/forwarding/index.js +3 -3
- package/dist_ts/http/models/http-types.js +1 -1
- package/dist_ts/http/port80/acme-interfaces.d.ts +30 -0
- package/dist_ts/http/port80/acme-interfaces.js +46 -1
- package/dist_ts/http/port80/port80-handler.d.ts +17 -2
- package/dist_ts/http/port80/port80-handler.js +49 -11
- package/dist_ts/http/router/index.d.ts +5 -1
- package/dist_ts/http/router/index.js +4 -2
- package/dist_ts/http/router/route-router.d.ts +108 -0
- package/dist_ts/http/router/route-router.js +393 -0
- package/dist_ts/index.d.ts +8 -2
- package/dist_ts/index.js +10 -3
- package/dist_ts/proxies/index.d.ts +7 -2
- package/dist_ts/proxies/index.js +10 -4
- package/dist_ts/proxies/network-proxy/certificate-manager.d.ts +21 -0
- package/dist_ts/proxies/network-proxy/certificate-manager.js +92 -1
- package/dist_ts/proxies/network-proxy/context-creator.d.ts +34 -0
- package/dist_ts/proxies/network-proxy/context-creator.js +108 -0
- package/dist_ts/proxies/network-proxy/function-cache.d.ts +90 -0
- package/dist_ts/proxies/network-proxy/function-cache.js +198 -0
- package/dist_ts/proxies/network-proxy/http-request-handler.d.ts +40 -0
- package/dist_ts/proxies/network-proxy/http-request-handler.js +256 -0
- package/dist_ts/proxies/network-proxy/http2-request-handler.d.ts +24 -0
- package/dist_ts/proxies/network-proxy/http2-request-handler.js +201 -0
- package/dist_ts/proxies/network-proxy/models/types.d.ts +73 -1
- package/dist_ts/proxies/network-proxy/models/types.js +242 -1
- package/dist_ts/proxies/network-proxy/network-proxy.d.ts +23 -20
- package/dist_ts/proxies/network-proxy/network-proxy.js +147 -60
- package/dist_ts/proxies/network-proxy/request-handler.d.ts +38 -5
- package/dist_ts/proxies/network-proxy/request-handler.js +584 -198
- package/dist_ts/proxies/network-proxy/security-manager.d.ts +65 -0
- package/dist_ts/proxies/network-proxy/security-manager.js +255 -0
- package/dist_ts/proxies/network-proxy/websocket-handler.d.ts +13 -2
- package/dist_ts/proxies/network-proxy/websocket-handler.js +238 -20
- package/dist_ts/proxies/smart-proxy/index.d.ts +1 -1
- package/dist_ts/proxies/smart-proxy/index.js +3 -3
- package/dist_ts/proxies/smart-proxy/models/interfaces.d.ts +5 -66
- package/dist_ts/proxies/smart-proxy/models/interfaces.js +5 -4
- package/dist_ts/proxies/smart-proxy/models/route-types.d.ts +173 -6
- package/dist_ts/proxies/smart-proxy/network-proxy-bridge.d.ts +20 -7
- package/dist_ts/proxies/smart-proxy/network-proxy-bridge.js +49 -108
- package/dist_ts/proxies/smart-proxy/port-manager.d.ts +81 -0
- package/dist_ts/proxies/smart-proxy/port-manager.js +166 -0
- package/dist_ts/proxies/smart-proxy/route-connection-handler.d.ts +7 -5
- package/dist_ts/proxies/smart-proxy/route-connection-handler.js +155 -160
- package/dist_ts/proxies/smart-proxy/route-helpers/index.d.ts +9 -0
- package/dist_ts/proxies/smart-proxy/route-helpers/index.js +11 -0
- package/dist_ts/proxies/smart-proxy/route-helpers.d.ts +5 -125
- package/dist_ts/proxies/smart-proxy/route-helpers.js +8 -195
- package/dist_ts/proxies/smart-proxy/route-manager.d.ts +14 -11
- package/dist_ts/proxies/smart-proxy/route-manager.js +81 -124
- package/dist_ts/proxies/smart-proxy/smart-proxy.d.ts +101 -12
- package/dist_ts/proxies/smart-proxy/smart-proxy.js +178 -306
- package/dist_ts/proxies/smart-proxy/timeout-manager.js +3 -3
- package/dist_ts/proxies/smart-proxy/utils/index.d.ts +12 -0
- package/dist_ts/proxies/smart-proxy/utils/index.js +19 -0
- package/dist_ts/proxies/smart-proxy/utils/route-helpers.d.ts +240 -0
- package/dist_ts/proxies/smart-proxy/utils/route-helpers.js +451 -0
- package/dist_ts/proxies/smart-proxy/utils/route-migration-utils.d.ts +51 -0
- package/dist_ts/proxies/smart-proxy/utils/route-migration-utils.js +124 -0
- package/dist_ts/proxies/smart-proxy/utils/route-patterns.d.ts +131 -0
- package/dist_ts/proxies/smart-proxy/utils/route-patterns.js +217 -0
- package/dist_ts/proxies/smart-proxy/utils/route-utils.d.ts +79 -0
- package/dist_ts/proxies/smart-proxy/utils/route-utils.js +266 -0
- package/dist_ts/proxies/smart-proxy/utils/route-validators.d.ts +73 -0
- package/dist_ts/proxies/smart-proxy/utils/route-validators.js +264 -0
- package/package.json +1 -1
- package/readme.md +241 -125
- package/readme.plan.md +73 -286
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/certificate/index.ts +17 -9
- package/ts/certificate/models/certificate-types.ts +37 -16
- package/ts/certificate/providers/cert-provisioner.ts +247 -54
- package/ts/core/models/index.ts +2 -0
- package/ts/core/models/route-context.ts +113 -0
- package/ts/core/models/socket-augmentation.ts +33 -0
- package/ts/core/utils/event-system.ts +376 -0
- package/ts/core/utils/index.ts +7 -0
- package/ts/core/utils/route-manager.ts +489 -0
- package/ts/core/utils/route-utils.ts +312 -0
- package/ts/core/utils/security-utils.ts +309 -0
- package/ts/core/utils/shared-security-manager.ts +333 -0
- package/ts/core/utils/template-utils.ts +124 -0
- package/ts/core/utils/websocket-utils.ts +81 -0
- package/ts/forwarding/config/forwarding-types.ts +79 -107
- package/ts/forwarding/config/index.ts +4 -2
- package/ts/forwarding/handlers/base-handler.ts +4 -2
- package/ts/forwarding/index.ts +3 -2
- package/ts/http/models/http-types.ts +0 -1
- package/ts/http/port80/acme-interfaces.ts +84 -0
- package/ts/http/port80/port80-handler.ts +61 -15
- package/ts/http/router/index.ts +8 -1
- package/ts/http/router/route-router.ts +482 -0
- package/ts/index.ts +14 -2
- package/ts/proxies/index.ts +12 -3
- package/ts/proxies/network-proxy/certificate-manager.ts +114 -10
- package/ts/proxies/network-proxy/context-creator.ts +145 -0
- package/ts/proxies/network-proxy/function-cache.ts +259 -0
- package/ts/proxies/network-proxy/http-request-handler.ts +330 -0
- package/ts/proxies/network-proxy/http2-request-handler.ts +255 -0
- package/ts/proxies/network-proxy/models/types.ts +312 -1
- package/ts/proxies/network-proxy/network-proxy.ts +195 -86
- package/ts/proxies/network-proxy/request-handler.ts +698 -246
- package/ts/proxies/network-proxy/security-manager.ts +298 -0
- package/ts/proxies/network-proxy/websocket-handler.ts +276 -33
- package/ts/proxies/smart-proxy/index.ts +2 -12
- package/ts/proxies/smart-proxy/models/interfaces.ts +13 -67
- package/ts/proxies/smart-proxy/models/route-types.ts +223 -25
- package/ts/proxies/smart-proxy/network-proxy-bridge.ts +57 -123
- package/ts/proxies/smart-proxy/port-manager.ts +195 -0
- package/ts/proxies/smart-proxy/route-connection-handler.ts +191 -225
- package/ts/proxies/smart-proxy/route-manager.ts +101 -144
- package/ts/proxies/smart-proxy/smart-proxy.ts +206 -377
- package/ts/proxies/smart-proxy/timeout-manager.ts +2 -2
- package/ts/proxies/smart-proxy/utils/index.ts +40 -0
- package/ts/proxies/smart-proxy/utils/route-helpers.ts +621 -0
- package/ts/proxies/smart-proxy/utils/route-migration-utils.ts +165 -0
- package/ts/proxies/smart-proxy/utils/route-patterns.ts +309 -0
- package/ts/proxies/smart-proxy/utils/route-utils.ts +330 -0
- package/ts/proxies/smart-proxy/utils/route-validators.ts +288 -0
- package/ts/forwarding/config/domain-config.ts +0 -28
- package/ts/forwarding/config/domain-manager.ts +0 -283
- package/ts/proxies/smart-proxy/connection-handler.ts +0 -1240
- package/ts/proxies/smart-proxy/domain-config-manager.ts +0 -441
- package/ts/proxies/smart-proxy/port-range-manager.ts +0 -211
- package/ts/proxies/smart-proxy/route-helpers.ts +0 -344
|
@@ -20,15 +20,5 @@ export { NetworkProxyBridge } from './network-proxy-bridge.js';
|
|
|
20
20
|
export { RouteManager } from './route-manager.js';
|
|
21
21
|
export { RouteConnectionHandler } from './route-connection-handler.js';
|
|
22
22
|
|
|
23
|
-
// Export
|
|
24
|
-
export
|
|
25
|
-
createRoute,
|
|
26
|
-
createHttpRoute,
|
|
27
|
-
createHttpsRoute,
|
|
28
|
-
createPassthroughRoute,
|
|
29
|
-
createRedirectRoute,
|
|
30
|
-
createHttpToHttpsRedirect,
|
|
31
|
-
createBlockRoute,
|
|
32
|
-
createLoadBalancerRoute,
|
|
33
|
-
createHttpsServer
|
|
34
|
-
} from './route-helpers.js';
|
|
23
|
+
// Export all helper functions from the utils directory
|
|
24
|
+
export * from './utils/index.js';
|
|
@@ -13,64 +13,17 @@ export type TSmartProxyCertProvisionObject = plugins.tsclass.network.ICert | 'ht
|
|
|
13
13
|
*/
|
|
14
14
|
export type IRoutedSmartProxyOptions = ISmartProxyOptions;
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
* Legacy domain configuration interface for backward compatibility
|
|
18
|
-
*/
|
|
19
|
-
export interface IDomainConfig {
|
|
20
|
-
domains: string[];
|
|
21
|
-
forwarding: {
|
|
22
|
-
type: TForwardingType;
|
|
23
|
-
target: {
|
|
24
|
-
host: string | string[];
|
|
25
|
-
port: number;
|
|
26
|
-
};
|
|
27
|
-
acme?: {
|
|
28
|
-
enabled?: boolean;
|
|
29
|
-
maintenance?: boolean;
|
|
30
|
-
production?: boolean;
|
|
31
|
-
forwardChallenges?: {
|
|
32
|
-
host: string;
|
|
33
|
-
port: number;
|
|
34
|
-
useTls?: boolean;
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
http?: {
|
|
38
|
-
enabled?: boolean;
|
|
39
|
-
redirectToHttps?: boolean;
|
|
40
|
-
headers?: Record<string, string>;
|
|
41
|
-
};
|
|
42
|
-
https?: {
|
|
43
|
-
customCert?: {
|
|
44
|
-
key: string;
|
|
45
|
-
cert: string;
|
|
46
|
-
};
|
|
47
|
-
forwardSni?: boolean;
|
|
48
|
-
};
|
|
49
|
-
security?: {
|
|
50
|
-
allowedIps?: string[];
|
|
51
|
-
blockedIps?: string[];
|
|
52
|
-
maxConnections?: number;
|
|
53
|
-
};
|
|
54
|
-
advanced?: {
|
|
55
|
-
portRanges?: Array<{ from: number; to: number }>;
|
|
56
|
-
networkProxyPort?: number;
|
|
57
|
-
keepAlive?: boolean;
|
|
58
|
-
timeout?: number;
|
|
59
|
-
headers?: Record<string, string>;
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
16
|
/**
|
|
65
17
|
* Helper functions for type checking configuration types
|
|
66
18
|
*/
|
|
67
19
|
export function isLegacyOptions(options: any): boolean {
|
|
68
|
-
|
|
69
|
-
|
|
20
|
+
// Legacy options are no longer supported
|
|
21
|
+
return false;
|
|
70
22
|
}
|
|
71
23
|
|
|
72
24
|
export function isRoutedOptions(options: any): boolean {
|
|
73
|
-
|
|
25
|
+
// All configurations are now route-based
|
|
26
|
+
return true;
|
|
74
27
|
}
|
|
75
28
|
|
|
76
29
|
/**
|
|
@@ -80,17 +33,8 @@ export interface ISmartProxyOptions {
|
|
|
80
33
|
// The unified configuration array (required)
|
|
81
34
|
routes: IRouteConfig[];
|
|
82
35
|
|
|
83
|
-
//
|
|
84
|
-
|
|
85
|
-
toPort?: number;
|
|
86
|
-
sniEnabled?: boolean;
|
|
87
|
-
domainConfigs?: IDomainConfig[];
|
|
88
|
-
targetIP?: string;
|
|
89
|
-
defaultAllowedIPs?: string[];
|
|
90
|
-
defaultBlockedIPs?: string[];
|
|
91
|
-
globalPortRanges?: Array<{ from: number; to: number }>;
|
|
92
|
-
forwardAllGlobalRanges?: boolean;
|
|
93
|
-
preserveSourceIP?: boolean;
|
|
36
|
+
// Port configuration
|
|
37
|
+
preserveSourceIP?: boolean; // Preserve client IP when forwarding
|
|
94
38
|
|
|
95
39
|
// Global/default settings
|
|
96
40
|
defaults?: {
|
|
@@ -99,8 +43,8 @@ export interface ISmartProxyOptions {
|
|
|
99
43
|
port: number; // Default port to use when not specified in routes
|
|
100
44
|
};
|
|
101
45
|
security?: {
|
|
102
|
-
|
|
103
|
-
|
|
46
|
+
allowedIps?: string[]; // Default allowed IPs
|
|
47
|
+
blockedIps?: string[]; // Default blocked IPs
|
|
104
48
|
maxConnections?: number; // Default max connections
|
|
105
49
|
};
|
|
106
50
|
preserveSourceIP?: boolean; // Default source IP preservation
|
|
@@ -184,9 +128,6 @@ export interface IConnectionRecord {
|
|
|
184
128
|
pendingData: Buffer[]; // Buffer to hold data during connection setup
|
|
185
129
|
pendingDataSize: number; // Track total size of pending data
|
|
186
130
|
|
|
187
|
-
// Legacy property for backward compatibility
|
|
188
|
-
domainConfig?: IDomainConfig;
|
|
189
|
-
|
|
190
131
|
// Enhanced tracking fields
|
|
191
132
|
bytesReceived: number; // Total bytes received
|
|
192
133
|
bytesSent: number; // Total bytes sent
|
|
@@ -197,6 +138,11 @@ export interface IConnectionRecord {
|
|
|
197
138
|
hasReceivedInitialData: boolean; // Whether initial data has been received
|
|
198
139
|
routeConfig?: IRouteConfig; // Associated route config for this connection
|
|
199
140
|
|
|
141
|
+
// Target information (for dynamic port/host mapping)
|
|
142
|
+
targetHost?: string; // Resolved target host
|
|
143
|
+
targetPort?: number; // Resolved target port
|
|
144
|
+
tlsVersion?: string; // TLS version (for routing context)
|
|
145
|
+
|
|
200
146
|
// Keep-alive tracking
|
|
201
147
|
hasKeepAlive: boolean; // Whether keep-alive is enabled for this connection
|
|
202
148
|
inactivityWarningIssued?: boolean; // Whether an inactivity warning has been issued
|
|
@@ -5,7 +5,7 @@ import type { TForwardingType } from '../../../forwarding/config/forwarding-type
|
|
|
5
5
|
/**
|
|
6
6
|
* Supported action types for route configurations
|
|
7
7
|
*/
|
|
8
|
-
export type TRouteActionType = 'forward' | 'redirect' | 'block';
|
|
8
|
+
export type TRouteActionType = 'forward' | 'redirect' | 'block' | 'static';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* TLS handling modes for route configurations
|
|
@@ -23,23 +23,54 @@ export type TPortRange = number | number[] | Array<{ from: number; to: number }>
|
|
|
23
23
|
export interface IRouteMatch {
|
|
24
24
|
// Listen on these ports (required)
|
|
25
25
|
ports: TPortRange;
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
// Optional domain patterns to match (default: all domains)
|
|
28
28
|
domains?: string | string[];
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
// Advanced matching criteria
|
|
31
31
|
path?: string; // Match specific paths
|
|
32
32
|
clientIp?: string[]; // Match specific client IPs
|
|
33
33
|
tlsVersion?: string[]; // Match specific TLS versions
|
|
34
|
+
headers?: Record<string, string | RegExp>; // Match specific HTTP headers
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Context provided to port and host mapping functions
|
|
39
|
+
*/
|
|
40
|
+
export interface IRouteContext {
|
|
41
|
+
// Connection information
|
|
42
|
+
port: number; // The matched incoming port
|
|
43
|
+
domain?: string; // The domain from SNI or Host header
|
|
44
|
+
clientIp: string; // The client's IP address
|
|
45
|
+
serverIp: string; // The server's IP address
|
|
46
|
+
path?: string; // URL path (for HTTP connections)
|
|
47
|
+
query?: string; // Query string (for HTTP connections)
|
|
48
|
+
headers?: Record<string, string>; // HTTP headers (for HTTP connections)
|
|
49
|
+
|
|
50
|
+
// TLS information
|
|
51
|
+
isTls: boolean; // Whether the connection is TLS
|
|
52
|
+
tlsVersion?: string; // TLS version if applicable
|
|
53
|
+
|
|
54
|
+
// Route information
|
|
55
|
+
routeName?: string; // The name of the matched route
|
|
56
|
+
routeId?: string; // The ID of the matched route
|
|
57
|
+
|
|
58
|
+
// Target information (resolved from dynamic mapping)
|
|
59
|
+
targetHost?: string | string[]; // The resolved target host(s)
|
|
60
|
+
targetPort?: number; // The resolved target port
|
|
61
|
+
|
|
62
|
+
// Additional properties
|
|
63
|
+
timestamp: number; // The request timestamp
|
|
64
|
+
connectionId: string; // Unique connection identifier
|
|
34
65
|
}
|
|
35
66
|
|
|
36
67
|
/**
|
|
37
68
|
* Target configuration for forwarding
|
|
38
69
|
*/
|
|
39
70
|
export interface IRouteTarget {
|
|
40
|
-
host: string | string[]; //
|
|
41
|
-
port: number;
|
|
42
|
-
preservePort?: boolean; // Use incoming port as target port
|
|
71
|
+
host: string | string[] | ((context: IRouteContext) => string | string[]); // Host or hosts with optional function for dynamic resolution
|
|
72
|
+
port: number | ((context: IRouteContext) => number); // Port with optional function for dynamic mapping
|
|
73
|
+
preservePort?: boolean; // Use incoming port as target port (ignored if port is a function)
|
|
43
74
|
}
|
|
44
75
|
|
|
45
76
|
/**
|
|
@@ -61,6 +92,26 @@ export interface IRouteRedirect {
|
|
|
61
92
|
status: 301 | 302 | 307 | 308;
|
|
62
93
|
}
|
|
63
94
|
|
|
95
|
+
/**
|
|
96
|
+
* Authentication options
|
|
97
|
+
*/
|
|
98
|
+
export interface IRouteAuthentication {
|
|
99
|
+
type: 'basic' | 'digest' | 'oauth' | 'jwt';
|
|
100
|
+
credentials?: {
|
|
101
|
+
username: string;
|
|
102
|
+
password: string;
|
|
103
|
+
}[];
|
|
104
|
+
realm?: string;
|
|
105
|
+
jwtSecret?: string;
|
|
106
|
+
jwtIssuer?: string;
|
|
107
|
+
oauthProvider?: string;
|
|
108
|
+
oauthClientId?: string;
|
|
109
|
+
oauthClientSecret?: string;
|
|
110
|
+
oauthRedirectUri?: string;
|
|
111
|
+
// Specific options for different auth types
|
|
112
|
+
options?: Record<string, unknown>;
|
|
113
|
+
}
|
|
114
|
+
|
|
64
115
|
/**
|
|
65
116
|
* Security options for route actions
|
|
66
117
|
*/
|
|
@@ -68,10 +119,41 @@ export interface IRouteSecurity {
|
|
|
68
119
|
allowedIps?: string[];
|
|
69
120
|
blockedIps?: string[];
|
|
70
121
|
maxConnections?: number;
|
|
71
|
-
authentication?:
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
122
|
+
authentication?: IRouteAuthentication;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Static file server configuration
|
|
127
|
+
*/
|
|
128
|
+
export interface IRouteStaticFiles {
|
|
129
|
+
root: string;
|
|
130
|
+
index?: string[];
|
|
131
|
+
headers?: Record<string, string>;
|
|
132
|
+
directory?: string;
|
|
133
|
+
indexFiles?: string[];
|
|
134
|
+
cacheControl?: string;
|
|
135
|
+
expires?: number;
|
|
136
|
+
followSymlinks?: boolean;
|
|
137
|
+
disableDirectoryListing?: boolean;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Test route response configuration
|
|
142
|
+
*/
|
|
143
|
+
export interface IRouteTestResponse {
|
|
144
|
+
status: number;
|
|
145
|
+
headers: Record<string, string>;
|
|
146
|
+
body: string;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* URL rewriting configuration
|
|
151
|
+
*/
|
|
152
|
+
export interface IRouteUrlRewrite {
|
|
153
|
+
pattern: string; // RegExp pattern to match in URL
|
|
154
|
+
target: string; // Replacement pattern (supports template variables like {domain})
|
|
155
|
+
flags?: string; // RegExp flags like 'g' for global replacement
|
|
156
|
+
onlyRewritePath?: boolean; // Only apply to path, not query string
|
|
75
157
|
}
|
|
76
158
|
|
|
77
159
|
/**
|
|
@@ -81,47 +163,163 @@ export interface IRouteAdvanced {
|
|
|
81
163
|
timeout?: number;
|
|
82
164
|
headers?: Record<string, string>;
|
|
83
165
|
keepAlive?: boolean;
|
|
166
|
+
staticFiles?: IRouteStaticFiles;
|
|
167
|
+
testResponse?: IRouteTestResponse;
|
|
168
|
+
urlRewrite?: IRouteUrlRewrite; // URL rewriting configuration
|
|
84
169
|
// Additional advanced options would go here
|
|
85
170
|
}
|
|
86
171
|
|
|
172
|
+
/**
|
|
173
|
+
* WebSocket configuration
|
|
174
|
+
*/
|
|
175
|
+
export interface IRouteWebSocket {
|
|
176
|
+
enabled: boolean; // Whether WebSockets are enabled for this route
|
|
177
|
+
pingInterval?: number; // Interval for sending ping frames (ms)
|
|
178
|
+
pingTimeout?: number; // Timeout for pong response (ms)
|
|
179
|
+
maxPayloadSize?: number; // Maximum message size in bytes
|
|
180
|
+
customHeaders?: Record<string, string>; // Custom headers for WebSocket handshake
|
|
181
|
+
subprotocols?: string[]; // Supported subprotocols
|
|
182
|
+
rewritePath?: string; // Path rewriting for WebSocket connections
|
|
183
|
+
allowedOrigins?: string[]; // Allowed origins for WebSocket connections
|
|
184
|
+
authenticateRequest?: boolean; // Whether to apply route security to WebSocket connections
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Load balancing configuration
|
|
189
|
+
*/
|
|
190
|
+
export interface IRouteLoadBalancing {
|
|
191
|
+
algorithm: 'round-robin' | 'least-connections' | 'ip-hash';
|
|
192
|
+
healthCheck?: {
|
|
193
|
+
path: string;
|
|
194
|
+
interval: number;
|
|
195
|
+
timeout: number;
|
|
196
|
+
unhealthyThreshold: number;
|
|
197
|
+
healthyThreshold: number;
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
87
201
|
/**
|
|
88
202
|
* Action configuration for route handling
|
|
89
203
|
*/
|
|
90
204
|
export interface IRouteAction {
|
|
91
205
|
// Basic routing
|
|
92
206
|
type: TRouteActionType;
|
|
93
|
-
|
|
207
|
+
|
|
94
208
|
// Target for forwarding
|
|
95
209
|
target?: IRouteTarget;
|
|
96
|
-
|
|
210
|
+
|
|
97
211
|
// TLS handling
|
|
98
212
|
tls?: IRouteTls;
|
|
99
|
-
|
|
213
|
+
|
|
100
214
|
// For redirects
|
|
101
215
|
redirect?: IRouteRedirect;
|
|
102
|
-
|
|
216
|
+
|
|
217
|
+
// For static files
|
|
218
|
+
static?: IRouteStaticFiles;
|
|
219
|
+
|
|
220
|
+
// WebSocket support
|
|
221
|
+
websocket?: IRouteWebSocket;
|
|
222
|
+
|
|
223
|
+
// Load balancing options
|
|
224
|
+
loadBalancing?: IRouteLoadBalancing;
|
|
225
|
+
|
|
103
226
|
// Security options
|
|
104
227
|
security?: IRouteSecurity;
|
|
105
|
-
|
|
228
|
+
|
|
106
229
|
// Advanced options
|
|
107
230
|
advanced?: IRouteAdvanced;
|
|
231
|
+
|
|
232
|
+
// Additional options for backend-specific settings
|
|
233
|
+
options?: {
|
|
234
|
+
backendProtocol?: 'http1' | 'http2';
|
|
235
|
+
[key: string]: any;
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Rate limiting configuration
|
|
241
|
+
*/
|
|
242
|
+
export interface IRouteRateLimit {
|
|
243
|
+
enabled: boolean;
|
|
244
|
+
maxRequests: number;
|
|
245
|
+
window: number; // Time window in seconds
|
|
246
|
+
keyBy?: 'ip' | 'path' | 'header';
|
|
247
|
+
headerName?: string;
|
|
248
|
+
errorMessage?: string;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Security features for routes
|
|
253
|
+
*/
|
|
254
|
+
export interface IRouteSecurity {
|
|
255
|
+
rateLimit?: IRouteRateLimit;
|
|
256
|
+
basicAuth?: {
|
|
257
|
+
enabled: boolean;
|
|
258
|
+
users: Array<{ username: string; password: string }>;
|
|
259
|
+
realm?: string;
|
|
260
|
+
excludePaths?: string[];
|
|
261
|
+
};
|
|
262
|
+
jwtAuth?: {
|
|
263
|
+
enabled: boolean;
|
|
264
|
+
secret: string;
|
|
265
|
+
algorithm?: string;
|
|
266
|
+
issuer?: string;
|
|
267
|
+
audience?: string;
|
|
268
|
+
expiresIn?: number;
|
|
269
|
+
excludePaths?: string[];
|
|
270
|
+
};
|
|
271
|
+
ipAllowList?: string[];
|
|
272
|
+
ipBlockList?: string[];
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* CORS configuration for a route
|
|
277
|
+
*/
|
|
278
|
+
export interface IRouteCors {
|
|
279
|
+
enabled: boolean; // Whether CORS is enabled for this route
|
|
280
|
+
allowOrigin?: string | string[]; // Allowed origins (*,domain.com,[domain1,domain2])
|
|
281
|
+
allowMethods?: string; // Allowed methods (GET,POST,etc.)
|
|
282
|
+
allowHeaders?: string; // Allowed headers
|
|
283
|
+
allowCredentials?: boolean; // Whether to allow credentials
|
|
284
|
+
exposeHeaders?: string; // Headers to expose to the client
|
|
285
|
+
maxAge?: number; // Preflight cache duration in seconds
|
|
286
|
+
preflight?: boolean; // Whether to respond to preflight requests
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Headers configuration
|
|
291
|
+
*/
|
|
292
|
+
export interface IRouteHeaders {
|
|
293
|
+
request?: Record<string, string>; // Headers to add/modify for requests to backend
|
|
294
|
+
response?: Record<string, string>; // Headers to add/modify for responses to client
|
|
295
|
+
cors?: IRouteCors; // CORS configuration
|
|
108
296
|
}
|
|
109
297
|
|
|
110
298
|
/**
|
|
111
299
|
* The core unified configuration interface
|
|
112
300
|
*/
|
|
113
301
|
export interface IRouteConfig {
|
|
302
|
+
// Unique identifier
|
|
303
|
+
id?: string;
|
|
304
|
+
|
|
114
305
|
// What to match
|
|
115
306
|
match: IRouteMatch;
|
|
116
|
-
|
|
307
|
+
|
|
117
308
|
// What to do with matched traffic
|
|
118
309
|
action: IRouteAction;
|
|
119
|
-
|
|
310
|
+
|
|
311
|
+
// Custom headers
|
|
312
|
+
headers?: IRouteHeaders;
|
|
313
|
+
|
|
314
|
+
// Security features
|
|
315
|
+
security?: IRouteSecurity;
|
|
316
|
+
|
|
120
317
|
// Optional metadata
|
|
121
318
|
name?: string; // Human-readable name for this route
|
|
122
319
|
description?: string; // Description of the route's purpose
|
|
123
320
|
priority?: number; // Controls matching order (higher = matched first)
|
|
124
321
|
tags?: string[]; // Arbitrary tags for categorization
|
|
322
|
+
enabled?: boolean; // Whether the route is active (default: true)
|
|
125
323
|
}
|
|
126
324
|
|
|
127
325
|
/**
|
|
@@ -130,7 +328,7 @@ export interface IRouteConfig {
|
|
|
130
328
|
export interface IRoutedSmartProxyOptions {
|
|
131
329
|
// The unified configuration array (required)
|
|
132
330
|
routes: IRouteConfig[];
|
|
133
|
-
|
|
331
|
+
|
|
134
332
|
// Global/default settings
|
|
135
333
|
defaults?: {
|
|
136
334
|
target?: {
|
|
@@ -141,10 +339,10 @@ export interface IRoutedSmartProxyOptions {
|
|
|
141
339
|
tls?: IRouteTls;
|
|
142
340
|
// ...other defaults
|
|
143
341
|
};
|
|
144
|
-
|
|
342
|
+
|
|
145
343
|
// Other global settings remain (acme, etc.)
|
|
146
344
|
acme?: IAcmeOptions;
|
|
147
|
-
|
|
345
|
+
|
|
148
346
|
// Connection timeouts and other global settings
|
|
149
347
|
initialDataTimeout?: number;
|
|
150
348
|
socketTimeout?: number;
|
|
@@ -152,13 +350,13 @@ export interface IRoutedSmartProxyOptions {
|
|
|
152
350
|
maxConnectionLifetime?: number;
|
|
153
351
|
inactivityTimeout?: number;
|
|
154
352
|
gracefulShutdownTimeout?: number;
|
|
155
|
-
|
|
353
|
+
|
|
156
354
|
// Socket optimization settings
|
|
157
355
|
noDelay?: boolean;
|
|
158
356
|
keepAlive?: boolean;
|
|
159
357
|
keepAliveInitialDelay?: number;
|
|
160
358
|
maxPendingDataSize?: number;
|
|
161
|
-
|
|
359
|
+
|
|
162
360
|
// Enhanced features
|
|
163
361
|
disableInactivityCheck?: boolean;
|
|
164
362
|
enableKeepAliveProbes?: boolean;
|
|
@@ -166,16 +364,16 @@ export interface IRoutedSmartProxyOptions {
|
|
|
166
364
|
enableTlsDebugLogging?: boolean;
|
|
167
365
|
enableRandomizedTimeouts?: boolean;
|
|
168
366
|
allowSessionTicket?: boolean;
|
|
169
|
-
|
|
367
|
+
|
|
170
368
|
// Rate limiting and security
|
|
171
369
|
maxConnectionsPerIP?: number;
|
|
172
370
|
connectionRateLimitPerMinute?: number;
|
|
173
|
-
|
|
371
|
+
|
|
174
372
|
// Enhanced keep-alive settings
|
|
175
373
|
keepAliveTreatment?: 'standard' | 'extended' | 'immortal';
|
|
176
374
|
keepAliveInactivityMultiplier?: number;
|
|
177
375
|
extendedKeepAliveLifetime?: number;
|
|
178
|
-
|
|
376
|
+
|
|
179
377
|
/**
|
|
180
378
|
* Optional certificate provider callback. Return 'http01' to use HTTP-01 challenges,
|
|
181
379
|
* or a static certificate object for immediate provisioning.
|