refactor: migrate coretraffic to current smartproxy

This commit is contained in:
2026-04-28 12:02:58 +00:00
parent ed595918e2
commit 44ce9c8900
12 changed files with 4391 additions and 3514 deletions
+14 -15
View File
@@ -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',
};
}
}