@push.rocks/smartproxy 16.0.3 → 17.0.0
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/common/port80-adapter.js +29 -3
- package/dist_ts/forwarding/config/forwarding-types.d.ts +3 -29
- package/dist_ts/forwarding/config/forwarding-types.js +3 -36
- package/dist_ts/forwarding/config/index.d.ts +3 -2
- package/dist_ts/forwarding/config/index.js +4 -3
- package/dist_ts/forwarding/factory/forwarding-factory.js +9 -3
- package/dist_ts/forwarding/handlers/base-handler.d.ts +4 -0
- package/dist_ts/forwarding/handlers/base-handler.js +25 -3
- package/dist_ts/forwarding/index.d.ts +3 -8
- package/dist_ts/forwarding/index.js +4 -13
- package/dist_ts/proxies/network-proxy/network-proxy.js +4 -2
- package/dist_ts/proxies/network-proxy/request-handler.js +3 -3
- package/dist_ts/proxies/network-proxy/websocket-handler.js +2 -2
- package/dist_ts/proxies/smart-proxy/models/index.d.ts +0 -1
- package/dist_ts/proxies/smart-proxy/models/interfaces.d.ts +0 -9
- package/dist_ts/proxies/smart-proxy/models/interfaces.js +1 -12
- package/dist_ts/proxies/smart-proxy/models/route-types.d.ts +1 -44
- package/dist_ts/proxies/smart-proxy/models/route-types.js +2 -1
- package/dist_ts/proxies/smart-proxy/route-connection-handler.d.ts +0 -3
- package/dist_ts/proxies/smart-proxy/route-connection-handler.js +8 -13
- package/dist_ts/proxies/smart-proxy/route-manager.js +2 -3
- package/dist_ts/proxies/smart-proxy/smart-proxy.js +2 -3
- package/dist_ts/proxies/smart-proxy/utils/index.d.ts +0 -2
- package/dist_ts/proxies/smart-proxy/utils/index.js +3 -6
- package/dist_ts/proxies/smart-proxy/utils/route-patterns.d.ts +48 -0
- package/dist_ts/proxies/smart-proxy/utils/route-patterns.js +106 -2
- package/package.json +1 -1
- package/readme.plan.md +175 -77
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/common/port80-adapter.ts +26 -2
- package/ts/forwarding/config/forwarding-types.ts +12 -70
- package/ts/forwarding/config/index.ts +19 -2
- package/ts/forwarding/factory/forwarding-factory.ts +7 -2
- package/ts/forwarding/handlers/base-handler.ts +22 -2
- package/ts/forwarding/index.ts +17 -17
- package/ts/proxies/network-proxy/network-proxy.ts +4 -1
- package/ts/proxies/network-proxy/request-handler.ts +2 -2
- package/ts/proxies/network-proxy/websocket-handler.ts +1 -1
- package/ts/proxies/smart-proxy/models/index.ts +0 -3
- package/ts/proxies/smart-proxy/models/interfaces.ts +1 -17
- package/ts/proxies/smart-proxy/models/route-types.ts +2 -60
- package/ts/proxies/smart-proxy/route-connection-handler.ts +4 -14
- package/ts/proxies/smart-proxy/route-manager.ts +3 -8
- package/ts/proxies/smart-proxy/smart-proxy.ts +2 -4
- package/ts/proxies/smart-proxy/utils/index.ts +2 -5
- package/ts/proxies/smart-proxy/utils/route-patterns.ts +146 -2
- package/ts/proxies/smart-proxy/utils/route-migration-utils.ts +0 -165
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Route Migration Utilities
|
|
3
|
-
*
|
|
4
|
-
* This file provides utility functions for migrating from legacy domain-based
|
|
5
|
-
* configuration to the new route-based configuration system. These functions
|
|
6
|
-
* are temporary and will be removed after the migration is complete.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import type { TForwardingType } from '../../../forwarding/config/forwarding-types.js';
|
|
10
|
-
import type { IRouteConfig, IRouteMatch, IRouteAction, IRouteTarget } from '../models/route-types.js';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Legacy domain config interface (for migration only)
|
|
14
|
-
* @deprecated This interface will be removed in a future version
|
|
15
|
-
*/
|
|
16
|
-
export interface ILegacyDomainConfig {
|
|
17
|
-
domains: string[];
|
|
18
|
-
forwarding: {
|
|
19
|
-
type: TForwardingType;
|
|
20
|
-
target: {
|
|
21
|
-
host: string | string[];
|
|
22
|
-
port: number;
|
|
23
|
-
};
|
|
24
|
-
[key: string]: any;
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Convert a legacy domain config to a route-based config
|
|
30
|
-
* @param domainConfig Legacy domain configuration
|
|
31
|
-
* @param additionalOptions Additional options to add to the route
|
|
32
|
-
* @returns Route configuration
|
|
33
|
-
* @deprecated This function will be removed in a future version
|
|
34
|
-
*/
|
|
35
|
-
export function domainConfigToRouteConfig(
|
|
36
|
-
domainConfig: ILegacyDomainConfig,
|
|
37
|
-
additionalOptions: Partial<IRouteConfig> = {}
|
|
38
|
-
): IRouteConfig {
|
|
39
|
-
// Default port based on forwarding type
|
|
40
|
-
let defaultPort = 80;
|
|
41
|
-
let tlsMode: 'passthrough' | 'terminate' | 'terminate-and-reencrypt' | undefined;
|
|
42
|
-
|
|
43
|
-
switch (domainConfig.forwarding.type) {
|
|
44
|
-
case 'http-only':
|
|
45
|
-
defaultPort = 80;
|
|
46
|
-
break;
|
|
47
|
-
case 'https-passthrough':
|
|
48
|
-
defaultPort = 443;
|
|
49
|
-
tlsMode = 'passthrough';
|
|
50
|
-
break;
|
|
51
|
-
case 'https-terminate-to-http':
|
|
52
|
-
defaultPort = 443;
|
|
53
|
-
tlsMode = 'terminate';
|
|
54
|
-
break;
|
|
55
|
-
case 'https-terminate-to-https':
|
|
56
|
-
defaultPort = 443;
|
|
57
|
-
tlsMode = 'terminate-and-reencrypt';
|
|
58
|
-
break;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Create route match criteria
|
|
62
|
-
const match: IRouteMatch = {
|
|
63
|
-
ports: additionalOptions.match?.ports || defaultPort,
|
|
64
|
-
domains: domainConfig.domains
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
// Create route target
|
|
68
|
-
const target: IRouteTarget = {
|
|
69
|
-
host: domainConfig.forwarding.target.host,
|
|
70
|
-
port: domainConfig.forwarding.target.port
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
// Create route action
|
|
74
|
-
const action: IRouteAction = {
|
|
75
|
-
type: 'forward',
|
|
76
|
-
target
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
// Add TLS configuration if needed
|
|
80
|
-
if (tlsMode) {
|
|
81
|
-
action.tls = {
|
|
82
|
-
mode: tlsMode,
|
|
83
|
-
certificate: 'auto'
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
// If the legacy config has custom certificates, use them
|
|
87
|
-
if (domainConfig.forwarding.https?.customCert) {
|
|
88
|
-
action.tls.certificate = {
|
|
89
|
-
key: domainConfig.forwarding.https.customCert.key,
|
|
90
|
-
cert: domainConfig.forwarding.https.customCert.cert
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// Add security options if present
|
|
96
|
-
if (domainConfig.forwarding.security) {
|
|
97
|
-
action.security = domainConfig.forwarding.security;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// Create the route config
|
|
101
|
-
const routeConfig: IRouteConfig = {
|
|
102
|
-
match,
|
|
103
|
-
action,
|
|
104
|
-
// Include a name based on domains if not provided
|
|
105
|
-
name: additionalOptions.name || `Legacy route for ${domainConfig.domains.join(', ')}`,
|
|
106
|
-
// Include a note that this was converted from a legacy config
|
|
107
|
-
description: additionalOptions.description || 'Converted from legacy domain configuration'
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
// Add optional properties if provided
|
|
111
|
-
if (additionalOptions.priority !== undefined) {
|
|
112
|
-
routeConfig.priority = additionalOptions.priority;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
if (additionalOptions.tags) {
|
|
116
|
-
routeConfig.tags = additionalOptions.tags;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return routeConfig;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Convert an array of legacy domain configs to route configurations
|
|
124
|
-
* @param domainConfigs Array of legacy domain configurations
|
|
125
|
-
* @returns Array of route configurations
|
|
126
|
-
* @deprecated This function will be removed in a future version
|
|
127
|
-
*/
|
|
128
|
-
export function domainConfigsToRouteConfigs(
|
|
129
|
-
domainConfigs: ILegacyDomainConfig[]
|
|
130
|
-
): IRouteConfig[] {
|
|
131
|
-
return domainConfigs.map(config => domainConfigToRouteConfig(config));
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Extract domains from a route configuration
|
|
136
|
-
* @param route Route configuration
|
|
137
|
-
* @returns Array of domains
|
|
138
|
-
*/
|
|
139
|
-
export function extractDomainsFromRoute(route: IRouteConfig): string[] {
|
|
140
|
-
if (!route.match.domains) {
|
|
141
|
-
return [];
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
return Array.isArray(route.match.domains)
|
|
145
|
-
? route.match.domains
|
|
146
|
-
: [route.match.domains];
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Extract domains from an array of route configurations
|
|
151
|
-
* @param routes Array of route configurations
|
|
152
|
-
* @returns Array of unique domains
|
|
153
|
-
*/
|
|
154
|
-
export function extractDomainsFromRoutes(routes: IRouteConfig[]): string[] {
|
|
155
|
-
const domains = new Set<string>();
|
|
156
|
-
|
|
157
|
-
for (const route of routes) {
|
|
158
|
-
const routeDomains = extractDomainsFromRoute(route);
|
|
159
|
-
for (const domain of routeDomains) {
|
|
160
|
-
domains.add(domain);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
return Array.from(domains);
|
|
165
|
-
}
|