@push.rocks/smartproxy 19.5.19 → 19.5.20

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 (101) hide show
  1. package/dist_ts/core/models/index.d.ts +2 -0
  2. package/dist_ts/core/models/index.js +3 -1
  3. package/dist_ts/core/models/socket-types.d.ts +14 -0
  4. package/dist_ts/core/models/socket-types.js +15 -0
  5. package/dist_ts/core/models/wrapped-socket.d.ts +34 -0
  6. package/dist_ts/core/models/wrapped-socket.js +82 -0
  7. package/dist_ts/core/routing/index.d.ts +11 -0
  8. package/dist_ts/core/routing/index.js +17 -0
  9. package/dist_ts/core/routing/matchers/domain.d.ts +34 -0
  10. package/dist_ts/core/routing/matchers/domain.js +91 -0
  11. package/dist_ts/core/routing/matchers/header.d.ts +32 -0
  12. package/dist_ts/core/routing/matchers/header.js +94 -0
  13. package/dist_ts/core/routing/matchers/index.d.ts +18 -0
  14. package/dist_ts/core/routing/matchers/index.js +20 -0
  15. package/dist_ts/core/routing/matchers/ip.d.ts +53 -0
  16. package/dist_ts/core/routing/matchers/ip.js +169 -0
  17. package/dist_ts/core/routing/matchers/path.d.ts +44 -0
  18. package/dist_ts/core/routing/matchers/path.js +148 -0
  19. package/dist_ts/core/routing/route-manager.d.ts +88 -0
  20. package/dist_ts/core/routing/route-manager.js +342 -0
  21. package/dist_ts/core/routing/route-utils.d.ts +28 -0
  22. package/dist_ts/core/routing/route-utils.js +67 -0
  23. package/dist_ts/core/routing/specificity.d.ts +30 -0
  24. package/dist_ts/core/routing/specificity.js +115 -0
  25. package/dist_ts/core/routing/types.d.ts +41 -0
  26. package/dist_ts/core/routing/types.js +5 -0
  27. package/dist_ts/core/utils/index.d.ts +0 -2
  28. package/dist_ts/core/utils/index.js +1 -3
  29. package/dist_ts/core/utils/route-manager.d.ts +0 -30
  30. package/dist_ts/core/utils/route-manager.js +6 -47
  31. package/dist_ts/core/utils/route-utils.d.ts +2 -68
  32. package/dist_ts/core/utils/route-utils.js +21 -218
  33. package/dist_ts/core/utils/security-utils.js +4 -4
  34. package/dist_ts/index.d.ts +2 -5
  35. package/dist_ts/index.js +5 -11
  36. package/dist_ts/proxies/http-proxy/http-proxy.d.ts +0 -1
  37. package/dist_ts/proxies/http-proxy/http-proxy.js +15 -60
  38. package/dist_ts/proxies/http-proxy/models/types.d.ts +0 -90
  39. package/dist_ts/proxies/http-proxy/models/types.js +1 -242
  40. package/dist_ts/proxies/http-proxy/request-handler.d.ts +3 -5
  41. package/dist_ts/proxies/http-proxy/request-handler.js +20 -171
  42. package/dist_ts/proxies/http-proxy/websocket-handler.d.ts +2 -5
  43. package/dist_ts/proxies/http-proxy/websocket-handler.js +15 -23
  44. package/dist_ts/proxies/index.d.ts +2 -2
  45. package/dist_ts/proxies/index.js +4 -3
  46. package/dist_ts/proxies/smart-proxy/connection-manager.d.ts +3 -1
  47. package/dist_ts/proxies/smart-proxy/connection-manager.js +15 -7
  48. package/dist_ts/proxies/smart-proxy/http-proxy-bridge.d.ts +2 -1
  49. package/dist_ts/proxies/smart-proxy/http-proxy-bridge.js +5 -2
  50. package/dist_ts/proxies/smart-proxy/index.d.ts +1 -1
  51. package/dist_ts/proxies/smart-proxy/index.js +2 -2
  52. package/dist_ts/proxies/smart-proxy/models/interfaces.d.ts +6 -2
  53. package/dist_ts/proxies/smart-proxy/route-connection-handler.d.ts +1 -1
  54. package/dist_ts/proxies/smart-proxy/route-connection-handler.js +48 -25
  55. package/dist_ts/proxies/smart-proxy/smart-proxy.d.ts +1 -1
  56. package/dist_ts/proxies/smart-proxy/smart-proxy.js +15 -4
  57. package/dist_ts/proxies/smart-proxy/utils/route-utils.js +10 -43
  58. package/dist_ts/routing/router/http-router.d.ts +89 -0
  59. package/dist_ts/routing/router/http-router.js +205 -0
  60. package/dist_ts/routing/router/index.d.ts +2 -5
  61. package/dist_ts/routing/router/index.js +3 -4
  62. package/package.json +1 -1
  63. package/readme.delete.md +187 -0
  64. package/readme.hints.md +189 -1
  65. package/readme.plan.md +621 -0
  66. package/readme.routing.md +341 -0
  67. package/ts/core/models/index.ts +2 -0
  68. package/ts/core/models/socket-types.ts +21 -0
  69. package/ts/core/models/wrapped-socket.ts +99 -0
  70. package/ts/core/routing/index.ts +21 -0
  71. package/ts/core/routing/matchers/domain.ts +119 -0
  72. package/ts/core/routing/matchers/header.ts +120 -0
  73. package/ts/core/routing/matchers/index.ts +22 -0
  74. package/ts/core/routing/matchers/ip.ts +207 -0
  75. package/ts/core/routing/matchers/path.ts +184 -0
  76. package/ts/core/{utils → routing}/route-manager.ts +7 -57
  77. package/ts/core/routing/route-utils.ts +88 -0
  78. package/ts/core/routing/specificity.ts +141 -0
  79. package/ts/core/routing/types.ts +49 -0
  80. package/ts/core/utils/index.ts +0 -2
  81. package/ts/core/utils/security-utils.ts +3 -7
  82. package/ts/index.ts +4 -14
  83. package/ts/proxies/http-proxy/http-proxy.ts +13 -68
  84. package/ts/proxies/http-proxy/models/types.ts +0 -324
  85. package/ts/proxies/http-proxy/request-handler.ts +15 -186
  86. package/ts/proxies/http-proxy/websocket-handler.ts +15 -26
  87. package/ts/proxies/index.ts +3 -2
  88. package/ts/proxies/smart-proxy/connection-manager.ts +15 -7
  89. package/ts/proxies/smart-proxy/http-proxy-bridge.ts +6 -2
  90. package/ts/proxies/smart-proxy/index.ts +1 -1
  91. package/ts/proxies/smart-proxy/models/interfaces.ts +8 -2
  92. package/ts/proxies/smart-proxy/route-connection-handler.ts +58 -30
  93. package/ts/proxies/smart-proxy/smart-proxy.ts +15 -3
  94. package/ts/proxies/smart-proxy/utils/route-utils.ts +11 -49
  95. package/ts/routing/router/http-router.ts +266 -0
  96. package/ts/routing/router/index.ts +3 -8
  97. package/readme.problems.md +0 -170
  98. package/ts/core/utils/route-utils.ts +0 -312
  99. package/ts/proxies/smart-proxy/route-manager.ts +0 -554
  100. package/ts/routing/router/proxy-router.ts +0 -437
  101. package/ts/routing/router/route-router.ts +0 -482
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Route matching utilities for SmartProxy components
3
+ *
4
+ * This file provides utility functions that use the unified matchers
5
+ * and additional route-specific utilities.
6
+ */
7
+
8
+ import { DomainMatcher, PathMatcher, IpMatcher, HeaderMatcher } from './matchers/index.js';
9
+ import { RouteSpecificity } from './specificity.js';
10
+ import type { IRouteSpecificity } from './types.js';
11
+ import type { IRouteConfig } from '../../proxies/smart-proxy/models/route-types.js';
12
+
13
+
14
+ /**
15
+ * Match domains from a route against a given domain
16
+ *
17
+ * @param domains Array or single domain pattern to match against
18
+ * @param domain Domain to match
19
+ * @returns Whether the domain matches any of the patterns
20
+ */
21
+ export function matchRouteDomain(domains: string | string[] | undefined, domain: string | undefined): boolean {
22
+ // If no domains specified in the route, match all domains
23
+ if (!domains) {
24
+ return true;
25
+ }
26
+
27
+ // If no domain in the request, can't match domain-specific routes
28
+ if (!domain) {
29
+ return false;
30
+ }
31
+
32
+ const patterns = Array.isArray(domains) ? domains : [domains];
33
+ return patterns.some(pattern => DomainMatcher.match(pattern, domain));
34
+ }
35
+
36
+
37
+
38
+ /**
39
+ * Calculate route specificity score
40
+ * Higher score means more specific matching criteria
41
+ *
42
+ * @param match Match criteria to evaluate
43
+ * @returns Numeric specificity score
44
+ */
45
+ export function calculateRouteSpecificity(match: {
46
+ domains?: string | string[];
47
+ path?: string;
48
+ clientIp?: string[];
49
+ tlsVersion?: string[];
50
+ headers?: Record<string, string | RegExp>;
51
+ }): number {
52
+ let score = 0;
53
+
54
+ // Path specificity using PathMatcher
55
+ if (match.path) {
56
+ score += PathMatcher.calculateSpecificity(match.path);
57
+ }
58
+
59
+ // Domain specificity using DomainMatcher
60
+ if (match.domains) {
61
+ const domains = Array.isArray(match.domains) ? match.domains : [match.domains];
62
+ // Use the highest specificity among all domains
63
+ const domainScore = Math.max(...domains.map(d => DomainMatcher.calculateSpecificity(d)));
64
+ score += domainScore;
65
+ }
66
+
67
+ // Headers specificity using HeaderMatcher
68
+ if (match.headers) {
69
+ const stringHeaders: Record<string, string> = {};
70
+ for (const [key, value] of Object.entries(match.headers)) {
71
+ stringHeaders[key] = value instanceof RegExp ? value.source : value;
72
+ }
73
+ score += HeaderMatcher.calculateSpecificity(stringHeaders);
74
+ }
75
+
76
+ // Client IP adds some specificity
77
+ if (match.clientIp && match.clientIp.length > 0) {
78
+ // Use the first IP pattern for specificity
79
+ score += IpMatcher.calculateSpecificity(match.clientIp[0]);
80
+ }
81
+
82
+ // TLS version adds minimal specificity
83
+ if (match.tlsVersion && match.tlsVersion.length > 0) {
84
+ score += match.tlsVersion.length * 10;
85
+ }
86
+
87
+ return score;
88
+ }
@@ -0,0 +1,141 @@
1
+ import type { IRouteConfig } from '../../proxies/smart-proxy/models/route-types.js';
2
+ import type { IRouteSpecificity } from './types.js';
3
+ import { DomainMatcher, PathMatcher, IpMatcher, HeaderMatcher } from './matchers/index.js';
4
+
5
+ /**
6
+ * Unified route specificity calculator
7
+ * Provides consistent specificity scoring across all routing components
8
+ */
9
+ export class RouteSpecificity {
10
+ /**
11
+ * Calculate the total specificity score for a route
12
+ * Higher scores indicate more specific routes that should match first
13
+ */
14
+ static calculate(route: IRouteConfig): IRouteSpecificity {
15
+ const specificity: IRouteSpecificity = {
16
+ pathSpecificity: 0,
17
+ domainSpecificity: 0,
18
+ ipSpecificity: 0,
19
+ headerSpecificity: 0,
20
+ tlsSpecificity: 0,
21
+ totalScore: 0
22
+ };
23
+
24
+ // Path specificity
25
+ if (route.match.path) {
26
+ specificity.pathSpecificity = PathMatcher.calculateSpecificity(route.match.path);
27
+ }
28
+
29
+ // Domain specificity
30
+ if (route.match.domains) {
31
+ const domains = Array.isArray(route.match.domains)
32
+ ? route.match.domains
33
+ : [route.match.domains];
34
+
35
+ // Use the highest specificity among all domains
36
+ specificity.domainSpecificity = Math.max(
37
+ ...domains.map(d => DomainMatcher.calculateSpecificity(d))
38
+ );
39
+ }
40
+
41
+ // IP specificity (clientIp is an array of IPs)
42
+ if (route.match.clientIp && route.match.clientIp.length > 0) {
43
+ // Use the first IP pattern for specificity calculation
44
+ specificity.ipSpecificity = IpMatcher.calculateSpecificity(route.match.clientIp[0]);
45
+ }
46
+
47
+ // Header specificity (convert RegExp values to strings)
48
+ if (route.match.headers) {
49
+ const stringHeaders: Record<string, string> = {};
50
+ for (const [key, value] of Object.entries(route.match.headers)) {
51
+ stringHeaders[key] = value instanceof RegExp ? value.source : value;
52
+ }
53
+ specificity.headerSpecificity = HeaderMatcher.calculateSpecificity(stringHeaders);
54
+ }
55
+
56
+ // TLS version specificity
57
+ if (route.match.tlsVersion && route.match.tlsVersion.length > 0) {
58
+ specificity.tlsSpecificity = route.match.tlsVersion.length * 10;
59
+ }
60
+
61
+ // Calculate total score with weights
62
+ specificity.totalScore =
63
+ specificity.pathSpecificity * 3 + // Path is most important
64
+ specificity.domainSpecificity * 2 + // Domain is second
65
+ specificity.ipSpecificity * 1.5 + // IP is moderately important
66
+ specificity.headerSpecificity * 1 + // Headers are less important
67
+ specificity.tlsSpecificity * 0.5; // TLS is least important
68
+
69
+ return specificity;
70
+ }
71
+
72
+ /**
73
+ * Compare two routes and determine which is more specific
74
+ * @returns positive if route1 is more specific, negative if route2 is more specific, 0 if equal
75
+ */
76
+ static compare(route1: IRouteConfig, route2: IRouteConfig): number {
77
+ const spec1 = this.calculate(route1);
78
+ const spec2 = this.calculate(route2);
79
+
80
+ // First compare by total score
81
+ if (spec1.totalScore !== spec2.totalScore) {
82
+ return spec1.totalScore - spec2.totalScore;
83
+ }
84
+
85
+ // If total scores are equal, compare by individual components
86
+ // Path is most important tiebreaker
87
+ if (spec1.pathSpecificity !== spec2.pathSpecificity) {
88
+ return spec1.pathSpecificity - spec2.pathSpecificity;
89
+ }
90
+
91
+ // Then domain
92
+ if (spec1.domainSpecificity !== spec2.domainSpecificity) {
93
+ return spec1.domainSpecificity - spec2.domainSpecificity;
94
+ }
95
+
96
+ // Then IP
97
+ if (spec1.ipSpecificity !== spec2.ipSpecificity) {
98
+ return spec1.ipSpecificity - spec2.ipSpecificity;
99
+ }
100
+
101
+ // Then headers
102
+ if (spec1.headerSpecificity !== spec2.headerSpecificity) {
103
+ return spec1.headerSpecificity - spec2.headerSpecificity;
104
+ }
105
+
106
+ // Finally TLS
107
+ return spec1.tlsSpecificity - spec2.tlsSpecificity;
108
+ }
109
+
110
+ /**
111
+ * Sort routes by specificity (most specific first)
112
+ */
113
+ static sort(routes: IRouteConfig[]): IRouteConfig[] {
114
+ return [...routes].sort((a, b) => this.compare(b, a));
115
+ }
116
+
117
+ /**
118
+ * Find the most specific route from a list
119
+ */
120
+ static findMostSpecific(routes: IRouteConfig[]): IRouteConfig | null {
121
+ if (routes.length === 0) return null;
122
+
123
+ return routes.reduce((most, current) =>
124
+ this.compare(current, most) > 0 ? current : most
125
+ );
126
+ }
127
+
128
+ /**
129
+ * Check if a route has any matching criteria
130
+ */
131
+ static hasMatchCriteria(route: IRouteConfig): boolean {
132
+ const match = route.match;
133
+ return !!(
134
+ match.domains ||
135
+ match.path ||
136
+ match.clientIp?.length ||
137
+ match.headers ||
138
+ match.tlsVersion?.length
139
+ );
140
+ }
141
+ }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Core routing types used throughout the routing system
3
+ */
4
+
5
+ export interface IPathMatchResult {
6
+ matches: boolean;
7
+ params?: Record<string, string>;
8
+ pathMatch?: string;
9
+ pathRemainder?: string;
10
+ }
11
+
12
+ export interface IRouteMatchResult {
13
+ matches: boolean;
14
+ score: number;
15
+ specificity: number;
16
+ matchedCriteria: string[];
17
+ }
18
+
19
+ export interface IDomainMatchOptions {
20
+ allowWildcards?: boolean;
21
+ caseInsensitive?: boolean;
22
+ }
23
+
24
+ export interface IIpMatchOptions {
25
+ allowCidr?: boolean;
26
+ allowRanges?: boolean;
27
+ }
28
+
29
+ export interface IHeaderMatchOptions {
30
+ caseInsensitive?: boolean;
31
+ exactMatch?: boolean;
32
+ }
33
+
34
+ export interface IRouteSpecificity {
35
+ pathSpecificity: number;
36
+ domainSpecificity: number;
37
+ ipSpecificity: number;
38
+ headerSpecificity: number;
39
+ tlsSpecificity: number;
40
+ totalScore: number;
41
+ }
42
+
43
+ export interface IMatcher<T = any, O = any> {
44
+ match(pattern: string, value: string, options?: O): T | boolean;
45
+ }
46
+
47
+ export interface IAsyncMatcher<T = any, O = any> {
48
+ match(pattern: string, value: string, options?: O): Promise<T | boolean>;
49
+ }
@@ -5,8 +5,6 @@
5
5
  export * from './validation-utils.js';
6
6
  export * from './ip-utils.js';
7
7
  export * from './template-utils.js';
8
- export * from './route-manager.js';
9
- export * from './route-utils.js';
10
8
  export * from './security-utils.js';
11
9
  export * from './shared-security-manager.js';
12
10
  export * from './websocket-utils.js';
@@ -1,9 +1,5 @@
1
1
  import * as plugins from '../../plugins.js';
2
- import {
3
- matchIpPattern,
4
- ipToNumber,
5
- matchIpCidr
6
- } from './route-utils.js';
2
+ import { IpMatcher } from '../routing/matchers/ip.js';
7
3
 
8
4
  /**
9
5
  * Security utilities for IP validation, rate limiting,
@@ -90,7 +86,7 @@ export function isIPAuthorized(
90
86
  // First check if IP is blocked - blocked IPs take precedence
91
87
  if (blockedIPs.length > 0) {
92
88
  for (const pattern of blockedIPs) {
93
- if (matchIpPattern(pattern, ip)) {
89
+ if (IpMatcher.match(pattern, ip)) {
94
90
  return false;
95
91
  }
96
92
  }
@@ -104,7 +100,7 @@ export function isIPAuthorized(
104
100
  // Then check if IP is allowed in the explicit allow list
105
101
  if (allowedIPs.length > 0) {
106
102
  for (const pattern of allowedIPs) {
107
- if (matchIpPattern(pattern, ip)) {
103
+ if (IpMatcher.match(pattern, ip)) {
108
104
  return true;
109
105
  }
110
106
  }
package/ts/index.ts CHANGED
@@ -2,28 +2,18 @@
2
2
  * SmartProxy main module exports
3
3
  */
4
4
 
5
- // Legacy exports (to maintain backward compatibility)
6
- // Migrated to the new proxies structure
5
+ // NFTables proxy exports
7
6
  export * from './proxies/nftables-proxy/index.js';
8
7
 
9
- // Export HttpProxy elements selectively to avoid RouteManager ambiguity
8
+ // Export HttpProxy elements
10
9
  export { HttpProxy, CertificateManager, ConnectionPool, RequestHandler, WebSocketHandler } from './proxies/http-proxy/index.js';
11
10
  export type { IMetricsTracker, MetricsTracker } from './proxies/http-proxy/index.js';
12
- // Export models except IAcmeOptions to avoid conflict
13
11
  export type { IHttpProxyOptions, ICertificateEntry, ILogger } from './proxies/http-proxy/models/types.js';
14
- export { RouteManager as HttpProxyRouteManager } from './proxies/http-proxy/models/types.js';
15
-
16
- // Backward compatibility exports (deprecated)
17
- export { HttpProxy as NetworkProxy } from './proxies/http-proxy/index.js';
18
- export type { IHttpProxyOptions as INetworkProxyOptions } from './proxies/http-proxy/models/types.js';
19
- export { HttpProxyBridge as NetworkProxyBridge } from './proxies/smart-proxy/index.js';
20
-
21
- // Certificate and Port80 modules have been removed - use SmartCertManager instead
22
- // Redirect module has been removed - use route-based redirects instead
12
+ export { SharedRouteManager as HttpProxyRouteManager } from './core/routing/route-manager.js';
23
13
 
24
14
  // Export SmartProxy elements selectively to avoid RouteManager ambiguity
25
15
  export { SmartProxy, ConnectionManager, SecurityManager, TimeoutManager, TlsManager, HttpProxyBridge, RouteConnectionHandler, SmartCertManager } from './proxies/smart-proxy/index.js';
26
- export { RouteManager } from './proxies/smart-proxy/route-manager.js';
16
+ export { SharedRouteManager as RouteManager } from './core/routing/route-manager.js';
27
17
  // Export smart-proxy models
28
18
  export type { ISmartProxyOptions, IConnectionRecord, IRouteConfig, IRouteMatch, IRouteAction, IRouteTls, IRouteContext } from './proxies/smart-proxy/models/index.js';
29
19
  export type { TSmartProxyCertProvisionObject } from './proxies/smart-proxy/models/interfaces.js';
@@ -1,13 +1,11 @@
1
1
  import * as plugins from '../../plugins.js';
2
2
  import {
3
3
  createLogger,
4
- RouteManager,
5
- convertLegacyConfigToRouteConfig
6
4
  } from './models/types.js';
5
+ import { SharedRouteManager as RouteManager } from '../../core/routing/route-manager.js';
7
6
  import type {
8
7
  IHttpProxyOptions,
9
- ILogger,
10
- IReverseProxyConfig
8
+ ILogger
11
9
  } from './models/types.js';
12
10
  import type { IRouteConfig } from '../smart-proxy/models/route-types.js';
13
11
  import type { IRouteContext, IHttpRouteContext } from '../../core/models/route-context.js';
@@ -16,8 +14,7 @@ import { CertificateManager } from './certificate-manager.js';
16
14
  import { ConnectionPool } from './connection-pool.js';
17
15
  import { RequestHandler, type IMetricsTracker } from './request-handler.js';
18
16
  import { WebSocketHandler } from './websocket-handler.js';
19
- import { ProxyRouter } from '../../routing/router/index.js';
20
- import { RouteRouter } from '../../routing/router/route-router.js';
17
+ import { HttpRouter } from '../../routing/router/index.js';
21
18
  import { cleanupSocket } from '../../core/utils/socket-utils.js';
22
19
  import { FunctionCache } from './function-cache.js';
23
20
 
@@ -43,8 +40,7 @@ export class HttpProxy implements IMetricsTracker {
43
40
  private connectionPool: ConnectionPool;
44
41
  private requestHandler: RequestHandler;
45
42
  private webSocketHandler: WebSocketHandler;
46
- private legacyRouter = new ProxyRouter(); // Legacy router for backward compatibility
47
- private router = new RouteRouter(); // New modern router
43
+ private router = new HttpRouter(); // Unified HTTP router
48
44
  private routeManager: RouteManager;
49
45
  private functionCache: FunctionCache;
50
46
 
@@ -87,7 +83,6 @@ export class HttpProxy implements IMetricsTracker {
87
83
  // Defaults for SmartProxy integration
88
84
  connectionPoolSize: optionsArg.connectionPoolSize || 50,
89
85
  portProxyIntegration: optionsArg.portProxyIntegration || false,
90
- useExternalPort80Handler: optionsArg.useExternalPort80Handler || false,
91
86
  // Backend protocol (http1 or http2)
92
87
  backendProtocol: optionsArg.backendProtocol || 'http1',
93
88
  // Default ACME options
@@ -107,7 +102,11 @@ export class HttpProxy implements IMetricsTracker {
107
102
  this.logger = createLogger(this.options.logLevel);
108
103
 
109
104
  // Initialize route manager
110
- this.routeManager = new RouteManager(this.logger);
105
+ this.routeManager = new RouteManager({
106
+ logger: this.logger,
107
+ enableDetailedLogging: this.options.logLevel === 'debug',
108
+ routes: []
109
+ });
111
110
 
112
111
  // Initialize function cache
113
112
  this.functionCache = new FunctionCache(this.logger, {
@@ -121,15 +120,13 @@ export class HttpProxy implements IMetricsTracker {
121
120
  this.requestHandler = new RequestHandler(
122
121
  this.options,
123
122
  this.connectionPool,
124
- this.legacyRouter, // Still use legacy router for backward compatibility
125
123
  this.routeManager,
126
124
  this.functionCache,
127
- this.router // Pass the new modern router as well
125
+ this.router
128
126
  );
129
127
  this.webSocketHandler = new WebSocketHandler(
130
128
  this.options,
131
129
  this.connectionPool,
132
- this.legacyRouter,
133
130
  this.routes // Pass current routes to WebSocketHandler
134
131
  );
135
132
 
@@ -429,65 +426,13 @@ export class HttpProxy implements IMetricsTracker {
429
426
  }
430
427
  }
431
428
 
432
- // Create legacy proxy configs for the router
433
- // This is only needed for backward compatibility with ProxyRouter
434
-
435
- const defaultPort = 443; // Default port for HTTPS when using 'preserve'
436
- // and will be removed in the future
437
- const legacyConfigs: IReverseProxyConfig[] = [];
438
-
439
- for (const domain of currentHostnames) {
440
- // Find route for this domain
441
- const route = routes.find(r => {
442
- const domains = Array.isArray(r.match.domains) ? r.match.domains : [r.match.domains];
443
- return domains.includes(domain);
444
- });
445
-
446
- if (!route || route.action.type !== 'forward' || !route.action.target) {
447
- continue;
448
- }
449
-
450
- // Skip routes with function-based targets - we'll handle them during request processing
451
- if (typeof route.action.target.host === 'function' || typeof route.action.target.port === 'function') {
452
- this.logger.info(`Domain ${domain} uses function-based targets - will be handled at request time`);
453
- continue;
454
- }
455
-
456
- // Extract static target information
457
- const targetHosts = Array.isArray(route.action.target.host)
458
- ? route.action.target.host
459
- : [route.action.target.host];
460
-
461
- // Handle 'preserve' port value
462
- const targetPort = route.action.target.port === 'preserve' ? defaultPort : route.action.target.port;
463
-
464
- // Get certificate information
465
- const certData = certificateUpdates.get(domain);
466
- const defaultCerts = this.certificateManager.getDefaultCertificates();
467
-
468
- legacyConfigs.push({
469
- hostName: domain,
470
- destinationIps: targetHosts,
471
- destinationPorts: [targetPort],
472
- privateKey: certData?.key || defaultCerts.key,
473
- publicKey: certData?.cert || defaultCerts.cert
474
- });
475
- }
476
-
477
- // Update the router with legacy configs
478
- // Handle both old and new router interfaces
479
- if (typeof this.router.setRoutes === 'function') {
480
- this.router.setRoutes(routes);
481
- } else if (typeof this.router.setNewProxyConfigs === 'function') {
482
- this.router.setNewProxyConfigs(legacyConfigs);
483
- } else {
484
- this.logger.warn('Router has no recognized configuration method');
485
- }
429
+ // Update the router with new routes
430
+ this.router.setRoutes(routes);
486
431
 
487
432
  // Update WebSocket handler with new routes
488
433
  this.webSocketHandler.setRoutes(routes);
489
434
 
490
- this.logger.info(`Route configuration updated with ${routes.length} routes and ${legacyConfigs.length} proxy configs`);
435
+ this.logger.info(`Route configuration updated with ${routes.length} routes`);
491
436
  }
492
437
 
493
438
  // Legacy methods have been removed.