This commit is contained in:
2025-05-10 00:26:03 +00:00
parent 95c5c1b90d
commit 200635e4bd
3 changed files with 181 additions and 25 deletions

View File

@ -113,12 +113,18 @@ export class SmartProxy extends plugins.EventEmitter {
this.timeoutManager
);
// Create domain config manager and port range manager (for backward compatibility)
this.domainConfigManager = new DomainConfigManager(this.settings);
this.portRangeManager = new PortRangeManager(this.settings);
// Create the new route manager
// Create the new route manager first
this.routeManager = new RouteManager(this.settings);
// Create domain config manager and port range manager
this.domainConfigManager = new DomainConfigManager(this.settings);
// Share the route manager with the domain config manager
if (typeof this.domainConfigManager.setRouteManager === 'function') {
this.domainConfigManager.setRouteManager(this.routeManager);
}
this.portRangeManager = new PortRangeManager(this.settings);
// Create other required components
this.tlsManager = new TlsManager(this.settings);
@ -178,10 +184,16 @@ export class SmartProxy extends plugins.EventEmitter {
return;
}
// If using legacy format, make sure domainConfigs are initialized
// Initialize domain config based on configuration type
if (isLegacyOptions(this.settings)) {
// Initialize domain config manager with the processed configs
this.domainConfigManager.updateDomainConfigs(this.settings.domainConfigs);
// Initialize domain config manager with the legacy domain configs
this.domainConfigManager.updateDomainConfigs(this.settings.domainConfigs || []);
} else if (isRoutedOptions(this.settings)) {
// For pure route-based configuration, the domain config is already initialized
// in the constructor, but we might need to regenerate it
if (typeof this.domainConfigManager.generateDomainConfigsFromRoutes === 'function') {
this.domainConfigManager.generateDomainConfigsFromRoutes();
}
}
// Initialize Port80Handler if enabled