2019-08-20 18:42:52 +02:00
|
|
|
import * as plugins from './smartproxy.plugins';
|
2019-08-22 12:49:29 +02:00
|
|
|
|
|
|
|
import { TProxyMasterCalls } from './smartproxy.classes.proxymaster';
|
2019-08-20 18:42:52 +02:00
|
|
|
|
|
|
|
export class SmartProxy {
|
|
|
|
|
2019-08-22 12:49:29 +02:00
|
|
|
public hostCandidates: plugins.tsclass.network.IReverseProxyConfig[] = [];
|
|
|
|
public proxyMasterFunctions: plugins.smartspawn.ModuleThread<TProxyMasterCalls>;
|
2019-08-20 18:42:52 +02:00
|
|
|
|
2019-08-22 12:49:29 +02:00
|
|
|
public addHostCandidate(hostCandidate: plugins.tsclass.network.IReverseProxyConfig) {
|
2019-08-20 18:42:52 +02:00
|
|
|
// TODO search for old hostCandidates with that target
|
|
|
|
this.hostCandidates.push(hostCandidate);
|
2019-08-20 18:43:15 +02:00
|
|
|
}
|
2019-08-20 18:42:52 +02:00
|
|
|
|
2019-08-22 12:49:29 +02:00
|
|
|
public async start () {
|
|
|
|
this.proxyMasterFunctions = await plugins.smartspawn.spawn<TProxyMasterCalls>(new plugins.smartspawn.Worker('./smartproxy.classes.proxymaster'));
|
|
|
|
console.log('successfully spawned proxymaster');
|
2019-08-22 13:20:41 +02:00
|
|
|
await this.proxyMasterFunctions.start();
|
2019-08-20 18:42:52 +02:00
|
|
|
}
|
|
|
|
|
2019-08-22 12:49:29 +02:00
|
|
|
public async stop () {
|
|
|
|
await this.proxyMasterFunctions.terminateMaster();
|
2019-08-20 18:42:52 +02:00
|
|
|
}
|
2019-08-21 23:41:06 +02:00
|
|
|
|
2019-08-21 23:54:55 +02:00
|
|
|
|
2019-08-20 18:42:52 +02:00
|
|
|
}
|