2025-05-04 10:10:07 +00:00
|
|
|
import * as plugins from '../plugins.js';
|
|
|
|
import * as paths from '../paths.js';
|
|
|
|
|
|
|
|
import { type IMtaConfig, MtaService } from '../mta/classes.mta.js';
|
|
|
|
|
|
|
|
export interface IDcRouterOptions {
|
|
|
|
portProxyConfig?: plugins.smartproxy.IPortProxySettings;
|
|
|
|
mtaConfig?: IMtaConfig;
|
|
|
|
dnsServerConfig?: plugins.smartdns.IDnsServerOptions;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DcRouter can be run on ingress and egress to and from a datacenter site.
|
|
|
|
*/
|
|
|
|
export class DcRouter {
|
|
|
|
private options: IDcRouterOptions;
|
|
|
|
public smartProxy: plugins.smartproxy.SmartProxy;
|
|
|
|
public mta: MtaService;
|
|
|
|
public dnsServer: plugins.smartdns.DnsServer;
|
|
|
|
constructor(optionsArg: IDcRouterOptions) {
|
|
|
|
this.options = optionsArg;
|
|
|
|
if (this.options.portProxyConfig) {
|
|
|
|
this.smartProxy = new plugins.smartproxy.SmartProxy(this.options.portProxyConfig);
|
|
|
|
}
|
|
|
|
if (this.options.mtaConfig) {
|
|
|
|
this.mta = new MtaService(null, this.options.mtaConfig);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public async start() {
|
|
|
|
if (this.smartProxy) {
|
|
|
|
await this.smartProxy.start();
|
|
|
|
}
|
|
|
|
if (this.mta) {
|
|
|
|
await this.mta.start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public async stop() {
|
|
|
|
if (this.smartProxy) {
|
|
|
|
await this.smartProxy.stop();
|
|
|
|
}
|
|
|
|
if (this.mta) {
|
|
|
|
await this.mta.stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default DcRouter;
|