refactor: migrate coretraffic to current smartproxy
This commit is contained in:
@@ -9,31 +9,26 @@ export interface ICoretrafficConfig {
|
||||
}
|
||||
|
||||
export class CoreTraffic {
|
||||
public projectinfo = new plugins.projectinfo.ProjectinfoNpm(paths.packageDir);
|
||||
public typedrouter = new plugins.typedrequest.TypedRouter();
|
||||
public projectinfo!: plugins.projectinfo.ProjectinfoNpm;
|
||||
public typedrouter: plugins.typedrequest.TypedRouter = new plugins.typedrequest.TypedRouter();
|
||||
public coreflowConnector: CoreflowConnector;
|
||||
public taskmanager: CoretrafficTaskManager;
|
||||
public networkProxy: plugins.smartproxy.NetworkProxy;
|
||||
public sslRedirect: plugins.smartproxy.SslRedirect;
|
||||
public smartProxy: plugins.smartproxy.SmartProxy;
|
||||
|
||||
constructor() {
|
||||
this.coreflowConnector = new CoreflowConnector(this);
|
||||
this.taskmanager = new CoretrafficTaskManager(this);
|
||||
this.networkProxy = new plugins.smartproxy.NetworkProxy({
|
||||
port: 8000
|
||||
this.smartProxy = new plugins.smartproxy.SmartProxy({
|
||||
routes: [],
|
||||
});
|
||||
this.sslRedirect = new plugins.smartproxy.SslRedirect(7999);
|
||||
}
|
||||
|
||||
/**
|
||||
* starts coretraffic
|
||||
*/
|
||||
public async start() {
|
||||
await this.networkProxy.start();
|
||||
await this.sslRedirect.start();
|
||||
this.networkProxy.addDefaultHeaders({
|
||||
servezone_coretraffic_version: this.projectinfo.version
|
||||
})
|
||||
this.projectinfo = await plugins.projectinfo.ProjectinfoNpm.create(paths.packageDir);
|
||||
await this.smartProxy.start();
|
||||
|
||||
await this.taskmanager.start();
|
||||
await this.coreflowConnector.start();
|
||||
@@ -47,9 +42,13 @@ export class CoreTraffic {
|
||||
console.log('stopped taskmanager');
|
||||
await this.coreflowConnector.stop();
|
||||
console.log('stopped coreflowConnector');
|
||||
await this.networkProxy.stop();
|
||||
await this.smartProxy.stop();
|
||||
console.log('stopped smartproxy!');
|
||||
await this.sslRedirect.stop();
|
||||
|
||||
}
|
||||
|
||||
public getDefaultResponseHeaders() {
|
||||
return {
|
||||
servezone_coretraffic_version: this.projectinfo?.version || 'unknown',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user