@push.rocks/smartproxy 16.0.2 → 16.0.4
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/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/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 +149 -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 +3 -5
- package/dist_ts/proxies/smart-proxy/models/route-types.d.ts +56 -4
- package/dist_ts/proxies/smart-proxy/network-proxy-bridge.d.ts +4 -57
- package/dist_ts/proxies/smart-proxy/network-proxy-bridge.js +19 -228
- 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 +5 -0
- package/dist_ts/proxies/smart-proxy/route-connection-handler.js +131 -15
- package/dist_ts/proxies/smart-proxy/route-helpers/index.d.ts +3 -1
- package/dist_ts/proxies/smart-proxy/route-helpers/index.js +5 -3
- package/dist_ts/proxies/smart-proxy/route-helpers.d.ts +5 -178
- package/dist_ts/proxies/smart-proxy/route-helpers.js +8 -296
- package/dist_ts/proxies/smart-proxy/route-manager.d.ts +11 -2
- package/dist_ts/proxies/smart-proxy/route-manager.js +79 -10
- package/dist_ts/proxies/smart-proxy/smart-proxy.d.ts +29 -2
- package/dist_ts/proxies/smart-proxy/smart-proxy.js +48 -43
- package/dist_ts/proxies/smart-proxy/utils/route-helpers.d.ts +67 -1
- package/dist_ts/proxies/smart-proxy/utils/route-helpers.js +120 -1
- package/dist_ts/proxies/smart-proxy/utils/route-validators.d.ts +3 -3
- package/dist_ts/proxies/smart-proxy/utils/route-validators.js +27 -5
- package/package.json +1 -1
- package/readme.md +102 -14
- package/readme.plan.md +103 -168
- package/ts/00_commitinfo_data.ts +1 -1
- 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/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 +197 -85
- 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 +7 -4
- package/ts/proxies/smart-proxy/models/route-types.ts +77 -10
- package/ts/proxies/smart-proxy/network-proxy-bridge.ts +20 -257
- package/ts/proxies/smart-proxy/port-manager.ts +195 -0
- package/ts/proxies/smart-proxy/route-connection-handler.ts +156 -21
- package/ts/proxies/smart-proxy/route-manager.ts +98 -14
- package/ts/proxies/smart-proxy/smart-proxy.ts +56 -55
- package/ts/proxies/smart-proxy/utils/route-helpers.ts +167 -1
- package/ts/proxies/smart-proxy/utils/route-validators.ts +24 -5
- package/ts/proxies/smart-proxy/domain-config-manager.ts.bak +0 -441
- package/ts/proxies/smart-proxy/route-helpers/index.ts +0 -9
- package/ts/proxies/smart-proxy/route-helpers.ts +0 -498
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
import * as plugins from '../../plugins.js';
|
|
2
2
|
import {
|
|
3
|
-
createLogger
|
|
3
|
+
createLogger,
|
|
4
|
+
RouteManager,
|
|
5
|
+
convertLegacyConfigToRouteConfig
|
|
4
6
|
} from './models/types.js';
|
|
5
7
|
import type {
|
|
6
8
|
INetworkProxyOptions,
|
|
7
9
|
ILogger,
|
|
8
10
|
IReverseProxyConfig
|
|
9
11
|
} from './models/types.js';
|
|
12
|
+
import type { IRouteConfig } from '../smart-proxy/models/route-types.js';
|
|
13
|
+
import type { IRouteContext, IHttpRouteContext } from '../../core/models/route-context.js';
|
|
14
|
+
import { createBaseRouteContext } from '../../core/models/route-context.js';
|
|
10
15
|
import { CertificateManager } from './certificate-manager.js';
|
|
11
16
|
import { ConnectionPool } from './connection-pool.js';
|
|
12
17
|
import { RequestHandler, type IMetricsTracker } from './request-handler.js';
|
|
13
18
|
import { WebSocketHandler } from './websocket-handler.js';
|
|
14
19
|
import { ProxyRouter } from '../../http/router/index.js';
|
|
20
|
+
import { RouteRouter } from '../../http/router/route-router.js';
|
|
15
21
|
import { Port80Handler } from '../../http/port80/port80-handler.js';
|
|
22
|
+
import { FunctionCache } from './function-cache.js';
|
|
16
23
|
|
|
17
24
|
/**
|
|
18
25
|
* NetworkProxy provides a reverse proxy with TLS termination, WebSocket support,
|
|
@@ -25,17 +32,20 @@ export class NetworkProxy implements IMetricsTracker {
|
|
|
25
32
|
}
|
|
26
33
|
// Configuration
|
|
27
34
|
public options: INetworkProxyOptions;
|
|
28
|
-
public
|
|
29
|
-
|
|
35
|
+
public routes: IRouteConfig[] = [];
|
|
36
|
+
|
|
30
37
|
// Server instances (HTTP/2 with HTTP/1 fallback)
|
|
31
38
|
public httpsServer: any;
|
|
32
|
-
|
|
39
|
+
|
|
33
40
|
// Core components
|
|
34
41
|
private certificateManager: CertificateManager;
|
|
35
42
|
private connectionPool: ConnectionPool;
|
|
36
43
|
private requestHandler: RequestHandler;
|
|
37
44
|
private webSocketHandler: WebSocketHandler;
|
|
38
|
-
private
|
|
45
|
+
private legacyRouter = new ProxyRouter(); // Legacy router for backward compatibility
|
|
46
|
+
private router = new RouteRouter(); // New modern router
|
|
47
|
+
private routeManager: RouteManager;
|
|
48
|
+
private functionCache: FunctionCache;
|
|
39
49
|
|
|
40
50
|
// State tracking
|
|
41
51
|
public socketMap = new plugins.lik.ObjectMap<plugins.net.Socket>();
|
|
@@ -94,15 +104,41 @@ export class NetworkProxy implements IMetricsTracker {
|
|
|
94
104
|
|
|
95
105
|
// Initialize logger
|
|
96
106
|
this.logger = createLogger(this.options.logLevel);
|
|
97
|
-
|
|
98
|
-
// Initialize
|
|
107
|
+
|
|
108
|
+
// Initialize route manager
|
|
109
|
+
this.routeManager = new RouteManager(this.logger);
|
|
110
|
+
|
|
111
|
+
// Initialize function cache
|
|
112
|
+
this.functionCache = new FunctionCache(this.logger, {
|
|
113
|
+
maxCacheSize: this.options.functionCacheSize || 1000,
|
|
114
|
+
defaultTtl: this.options.functionCacheTtl || 5000
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
// Initialize other components
|
|
99
118
|
this.certificateManager = new CertificateManager(this.options);
|
|
100
119
|
this.connectionPool = new ConnectionPool(this.options);
|
|
101
|
-
this.requestHandler = new RequestHandler(
|
|
102
|
-
|
|
103
|
-
|
|
120
|
+
this.requestHandler = new RequestHandler(
|
|
121
|
+
this.options,
|
|
122
|
+
this.connectionPool,
|
|
123
|
+
this.legacyRouter, // Still use legacy router for backward compatibility
|
|
124
|
+
this.routeManager,
|
|
125
|
+
this.functionCache,
|
|
126
|
+
this.router // Pass the new modern router as well
|
|
127
|
+
);
|
|
128
|
+
this.webSocketHandler = new WebSocketHandler(
|
|
129
|
+
this.options,
|
|
130
|
+
this.connectionPool,
|
|
131
|
+
this.legacyRouter,
|
|
132
|
+
this.routes // Pass current routes to WebSocketHandler
|
|
133
|
+
);
|
|
134
|
+
|
|
104
135
|
// Connect request handler to this metrics tracker
|
|
105
136
|
this.requestHandler.setMetricsTracker(this);
|
|
137
|
+
|
|
138
|
+
// Initialize with any provided routes
|
|
139
|
+
if (this.options.routes && this.options.routes.length > 0) {
|
|
140
|
+
this.updateRouteConfigs(this.options.routes);
|
|
141
|
+
}
|
|
106
142
|
}
|
|
107
143
|
|
|
108
144
|
/**
|
|
@@ -124,6 +160,14 @@ export class NetworkProxy implements IMetricsTracker {
|
|
|
124
160
|
* Useful for SmartProxy to determine where to forward connections
|
|
125
161
|
*/
|
|
126
162
|
public getListeningPort(): number {
|
|
163
|
+
// If the server is running, get the actual listening port
|
|
164
|
+
if (this.httpsServer && this.httpsServer.address()) {
|
|
165
|
+
const address = this.httpsServer.address();
|
|
166
|
+
if (address && typeof address === 'object' && 'port' in address) {
|
|
167
|
+
return address.port;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
// Fallback to configured port
|
|
127
171
|
return this.options.port;
|
|
128
172
|
}
|
|
129
173
|
|
|
@@ -171,7 +215,8 @@ export class NetworkProxy implements IMetricsTracker {
|
|
|
171
215
|
connectionPoolSize: this.connectionPool.getPoolStatus(),
|
|
172
216
|
uptime: Math.floor((Date.now() - this.startTime) / 1000),
|
|
173
217
|
memoryUsage: process.memoryUsage(),
|
|
174
|
-
activeWebSockets: this.webSocketHandler.getConnectionInfo().activeConnections
|
|
218
|
+
activeWebSockets: this.webSocketHandler.getConnectionInfo().activeConnections,
|
|
219
|
+
functionCache: this.functionCache.getStats()
|
|
175
220
|
};
|
|
176
221
|
}
|
|
177
222
|
|
|
@@ -325,96 +370,142 @@ export class NetworkProxy implements IMetricsTracker {
|
|
|
325
370
|
}
|
|
326
371
|
|
|
327
372
|
/**
|
|
328
|
-
* Updates
|
|
373
|
+
* Updates the route configurations - this is the primary method for configuring NetworkProxy
|
|
374
|
+
* @param routes The new route configurations to use
|
|
329
375
|
*/
|
|
330
|
-
public async
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
this.
|
|
337
|
-
this.
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
376
|
+
public async updateRouteConfigs(routes: IRouteConfig[]): Promise<void> {
|
|
377
|
+
this.logger.info(`Updating route configurations (${routes.length} routes)`);
|
|
378
|
+
|
|
379
|
+
// Update routes in RouteManager, modern router, WebSocketHandler, and SecurityManager
|
|
380
|
+
this.routeManager.updateRoutes(routes);
|
|
381
|
+
this.router.setRoutes(routes);
|
|
382
|
+
this.webSocketHandler.setRoutes(routes);
|
|
383
|
+
this.requestHandler.securityManager.setRoutes(routes);
|
|
384
|
+
this.routes = routes;
|
|
385
|
+
|
|
386
|
+
// Directly update the certificate manager with the new routes
|
|
387
|
+
// This will extract domains and handle certificate provisioning
|
|
388
|
+
this.certificateManager.updateRouteConfigs(routes);
|
|
389
|
+
|
|
390
|
+
// Collect all domains and certificates for configuration
|
|
391
|
+
const currentHostnames = new Set<string>();
|
|
392
|
+
const certificateUpdates = new Map<string, { cert: string, key: string }>();
|
|
393
|
+
|
|
394
|
+
// Process each route to extract domain and certificate information
|
|
395
|
+
for (const route of routes) {
|
|
396
|
+
// Skip non-forward routes or routes without domains
|
|
397
|
+
if (route.action.type !== 'forward' || !route.match.domains) {
|
|
398
|
+
continue;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
// Get domains from route
|
|
402
|
+
const domains = Array.isArray(route.match.domains)
|
|
403
|
+
? route.match.domains
|
|
404
|
+
: [route.match.domains];
|
|
405
|
+
|
|
406
|
+
// Process each domain
|
|
407
|
+
for (const domain of domains) {
|
|
408
|
+
// Skip wildcard domains for direct host configuration
|
|
409
|
+
if (domain.includes('*')) {
|
|
410
|
+
continue;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
currentHostnames.add(domain);
|
|
414
|
+
|
|
415
|
+
// Check if we have a static certificate for this domain
|
|
416
|
+
if (route.action.tls?.certificate && route.action.tls.certificate !== 'auto') {
|
|
417
|
+
certificateUpdates.set(domain, {
|
|
418
|
+
cert: route.action.tls.certificate.cert,
|
|
419
|
+
key: route.action.tls.certificate.key
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
// Update certificate cache with any static certificates
|
|
426
|
+
for (const [domain, certData] of certificateUpdates.entries()) {
|
|
346
427
|
try {
|
|
347
|
-
// Update certificate in cache
|
|
348
428
|
this.certificateManager.updateCertificateCache(
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
429
|
+
domain,
|
|
430
|
+
certData.cert,
|
|
431
|
+
certData.key
|
|
352
432
|
);
|
|
353
|
-
|
|
354
|
-
this.activeContexts.add(
|
|
433
|
+
|
|
434
|
+
this.activeContexts.add(domain);
|
|
355
435
|
} catch (error) {
|
|
356
|
-
this.logger.error(`Failed to add SSL context for ${
|
|
436
|
+
this.logger.error(`Failed to add SSL context for ${domain}`, error);
|
|
357
437
|
}
|
|
358
438
|
}
|
|
359
|
-
|
|
439
|
+
|
|
360
440
|
// Clean up removed contexts
|
|
361
441
|
for (const hostname of this.activeContexts) {
|
|
362
|
-
if (!
|
|
442
|
+
if (!currentHostnames.has(hostname)) {
|
|
363
443
|
this.logger.info(`Hostname ${hostname} removed from configuration`);
|
|
364
444
|
this.activeContexts.delete(hostname);
|
|
365
445
|
}
|
|
366
446
|
}
|
|
367
|
-
|
|
368
|
-
// Register domains with Port80Handler if available
|
|
369
|
-
const domainsForACME = Array.from(currentHostNames)
|
|
370
|
-
.filter(domain => !domain.includes('*')); // Skip wildcard domains
|
|
371
|
-
|
|
372
|
-
this.certificateManager.registerDomainsWithPort80Handler(domainsForACME);
|
|
373
|
-
}
|
|
374
447
|
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
* @param domainConfigs SmartProxy domain configs
|
|
378
|
-
* @param sslKeyPair Default SSL key pair to use if not specified
|
|
379
|
-
* @returns Array of NetworkProxy configs
|
|
380
|
-
*/
|
|
381
|
-
public convertSmartProxyConfigs(
|
|
382
|
-
domainConfigs: Array<{
|
|
383
|
-
domains: string[];
|
|
384
|
-
targetIPs?: string[];
|
|
385
|
-
allowedIPs?: string[];
|
|
386
|
-
}>,
|
|
387
|
-
sslKeyPair?: { key: string; cert: string }
|
|
388
|
-
): IReverseProxyConfig[] {
|
|
389
|
-
const proxyConfigs: IReverseProxyConfig[] = [];
|
|
390
|
-
|
|
391
|
-
// Use default certificates if not provided
|
|
392
|
-
const defaultCerts = this.certificateManager.getDefaultCertificates();
|
|
393
|
-
const sslKey = sslKeyPair?.key || defaultCerts.key;
|
|
394
|
-
const sslCert = sslKeyPair?.cert || defaultCerts.cert;
|
|
448
|
+
// Create legacy proxy configs for the router
|
|
449
|
+
// This is only needed for backward compatibility with ProxyRouter
|
|
395
450
|
|
|
396
|
-
for
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
451
|
+
const defaultPort = 443; // Default port for HTTPS when using 'preserve'
|
|
452
|
+
// and will be removed in the future
|
|
453
|
+
const legacyConfigs: IReverseProxyConfig[] = [];
|
|
454
|
+
|
|
455
|
+
for (const domain of currentHostnames) {
|
|
456
|
+
// Find route for this domain
|
|
457
|
+
const route = routes.find(r => {
|
|
458
|
+
const domains = Array.isArray(r.match.domains) ? r.match.domains : [r.match.domains];
|
|
459
|
+
return domains.includes(domain);
|
|
460
|
+
});
|
|
461
|
+
|
|
462
|
+
if (!route || route.action.type !== 'forward' || !route.action.target) {
|
|
463
|
+
continue;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
// Skip routes with function-based targets - we'll handle them during request processing
|
|
467
|
+
if (typeof route.action.target.host === 'function' || typeof route.action.target.port === 'function') {
|
|
468
|
+
this.logger.info(`Domain ${domain} uses function-based targets - will be handled at request time`);
|
|
469
|
+
continue;
|
|
411
470
|
}
|
|
471
|
+
|
|
472
|
+
// Extract static target information
|
|
473
|
+
const targetHosts = Array.isArray(route.action.target.host)
|
|
474
|
+
? route.action.target.host
|
|
475
|
+
: [route.action.target.host];
|
|
476
|
+
|
|
477
|
+
// Handle 'preserve' port value
|
|
478
|
+
const targetPort = route.action.target.port === 'preserve' ? defaultPort : route.action.target.port;
|
|
479
|
+
|
|
480
|
+
// Get certificate information
|
|
481
|
+
const certData = certificateUpdates.get(domain);
|
|
482
|
+
const defaultCerts = this.certificateManager.getDefaultCertificates();
|
|
483
|
+
|
|
484
|
+
legacyConfigs.push({
|
|
485
|
+
hostName: domain,
|
|
486
|
+
destinationIps: targetHosts,
|
|
487
|
+
destinationPorts: [targetPort],
|
|
488
|
+
privateKey: certData?.key || defaultCerts.key,
|
|
489
|
+
publicKey: certData?.cert || defaultCerts.cert
|
|
490
|
+
});
|
|
412
491
|
}
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
492
|
+
|
|
493
|
+
// Update the router with legacy configs
|
|
494
|
+
// Handle both old and new router interfaces
|
|
495
|
+
if (typeof this.router.setRoutes === 'function') {
|
|
496
|
+
this.router.setRoutes(routes);
|
|
497
|
+
} else if (typeof this.router.setNewProxyConfigs === 'function') {
|
|
498
|
+
this.router.setNewProxyConfigs(legacyConfigs);
|
|
499
|
+
} else {
|
|
500
|
+
this.logger.warn('Router has no recognized configuration method');
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
this.logger.info(`Route configuration updated with ${routes.length} routes and ${legacyConfigs.length} proxy configs`);
|
|
416
504
|
}
|
|
417
505
|
|
|
506
|
+
// Legacy methods have been removed.
|
|
507
|
+
// Please use updateRouteConfigs() directly with modern route-based configuration.
|
|
508
|
+
|
|
418
509
|
/**
|
|
419
510
|
* Adds default headers to be included in all responses
|
|
420
511
|
*/
|
|
@@ -474,11 +565,32 @@ export class NetworkProxy implements IMetricsTracker {
|
|
|
474
565
|
public async requestCertificate(domain: string): Promise<boolean> {
|
|
475
566
|
return this.certificateManager.requestCertificate(domain);
|
|
476
567
|
}
|
|
568
|
+
|
|
569
|
+
/**
|
|
570
|
+
* Update certificate for a domain
|
|
571
|
+
*
|
|
572
|
+
* This method allows direct updates of certificates from external sources
|
|
573
|
+
* like Port80Handler or custom certificate providers.
|
|
574
|
+
*
|
|
575
|
+
* @param domain The domain to update certificate for
|
|
576
|
+
* @param certificate The new certificate (public key)
|
|
577
|
+
* @param privateKey The new private key
|
|
578
|
+
* @param expiryDate Optional expiry date
|
|
579
|
+
*/
|
|
580
|
+
public updateCertificate(
|
|
581
|
+
domain: string,
|
|
582
|
+
certificate: string,
|
|
583
|
+
privateKey: string,
|
|
584
|
+
expiryDate?: Date
|
|
585
|
+
): void {
|
|
586
|
+
this.logger.info(`Updating certificate for ${domain}`);
|
|
587
|
+
this.certificateManager.updateCertificateCache(domain, certificate, privateKey, expiryDate);
|
|
588
|
+
}
|
|
477
589
|
|
|
478
590
|
/**
|
|
479
|
-
* Gets all
|
|
591
|
+
* Gets all route configurations currently in use
|
|
480
592
|
*/
|
|
481
|
-
public
|
|
482
|
-
return
|
|
593
|
+
public getRouteConfigs(): IRouteConfig[] {
|
|
594
|
+
return this.routeManager.getRoutes();
|
|
483
595
|
}
|
|
484
596
|
}
|