@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.
Files changed (48) hide show
  1. package/dist_ts/00_commitinfo_data.js +1 -1
  2. package/dist_ts/common/port80-adapter.js +29 -3
  3. package/dist_ts/forwarding/config/forwarding-types.d.ts +3 -29
  4. package/dist_ts/forwarding/config/forwarding-types.js +3 -36
  5. package/dist_ts/forwarding/config/index.d.ts +3 -2
  6. package/dist_ts/forwarding/config/index.js +4 -3
  7. package/dist_ts/forwarding/factory/forwarding-factory.js +9 -3
  8. package/dist_ts/forwarding/handlers/base-handler.d.ts +4 -0
  9. package/dist_ts/forwarding/handlers/base-handler.js +25 -3
  10. package/dist_ts/forwarding/index.d.ts +3 -8
  11. package/dist_ts/forwarding/index.js +4 -13
  12. package/dist_ts/proxies/network-proxy/network-proxy.js +4 -2
  13. package/dist_ts/proxies/network-proxy/request-handler.js +3 -3
  14. package/dist_ts/proxies/network-proxy/websocket-handler.js +2 -2
  15. package/dist_ts/proxies/smart-proxy/models/index.d.ts +0 -1
  16. package/dist_ts/proxies/smart-proxy/models/interfaces.d.ts +0 -9
  17. package/dist_ts/proxies/smart-proxy/models/interfaces.js +1 -12
  18. package/dist_ts/proxies/smart-proxy/models/route-types.d.ts +1 -44
  19. package/dist_ts/proxies/smart-proxy/models/route-types.js +2 -1
  20. package/dist_ts/proxies/smart-proxy/route-connection-handler.d.ts +0 -3
  21. package/dist_ts/proxies/smart-proxy/route-connection-handler.js +8 -13
  22. package/dist_ts/proxies/smart-proxy/route-manager.js +2 -3
  23. package/dist_ts/proxies/smart-proxy/smart-proxy.js +2 -3
  24. package/dist_ts/proxies/smart-proxy/utils/index.d.ts +0 -2
  25. package/dist_ts/proxies/smart-proxy/utils/index.js +3 -6
  26. package/dist_ts/proxies/smart-proxy/utils/route-patterns.d.ts +48 -0
  27. package/dist_ts/proxies/smart-proxy/utils/route-patterns.js +106 -2
  28. package/package.json +1 -1
  29. package/readme.plan.md +175 -77
  30. package/ts/00_commitinfo_data.ts +1 -1
  31. package/ts/common/port80-adapter.ts +26 -2
  32. package/ts/forwarding/config/forwarding-types.ts +12 -70
  33. package/ts/forwarding/config/index.ts +19 -2
  34. package/ts/forwarding/factory/forwarding-factory.ts +7 -2
  35. package/ts/forwarding/handlers/base-handler.ts +22 -2
  36. package/ts/forwarding/index.ts +17 -17
  37. package/ts/proxies/network-proxy/network-proxy.ts +4 -1
  38. package/ts/proxies/network-proxy/request-handler.ts +2 -2
  39. package/ts/proxies/network-proxy/websocket-handler.ts +1 -1
  40. package/ts/proxies/smart-proxy/models/index.ts +0 -3
  41. package/ts/proxies/smart-proxy/models/interfaces.ts +1 -17
  42. package/ts/proxies/smart-proxy/models/route-types.ts +2 -60
  43. package/ts/proxies/smart-proxy/route-connection-handler.ts +4 -14
  44. package/ts/proxies/smart-proxy/route-manager.ts +3 -8
  45. package/ts/proxies/smart-proxy/smart-proxy.ts +2 -4
  46. package/ts/proxies/smart-proxy/utils/index.ts +2 -5
  47. package/ts/proxies/smart-proxy/utils/route-patterns.ts +146 -2
  48. 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
- }