2019-08-20 16:42:52 +00:00
|
|
|
import * as plugins from './smartproxy.plugins';
|
2019-08-22 10:49:29 +00:00
|
|
|
|
|
|
|
import { TProxyMasterCalls } from './smartproxy.classes.proxymaster';
|
2019-08-20 16:42:52 +00:00
|
|
|
|
|
|
|
export class SmartProxy {
|
|
|
|
|
2019-08-22 10:49:29 +00:00
|
|
|
public hostCandidates: plugins.tsclass.network.IReverseProxyConfig[] = [];
|
|
|
|
public proxyMasterFunctions: plugins.smartspawn.ModuleThread<TProxyMasterCalls>;
|
2019-08-20 16:42:52 +00:00
|
|
|
|
2019-08-22 10:49:29 +00:00
|
|
|
public addHostCandidate(hostCandidate: plugins.tsclass.network.IReverseProxyConfig) {
|
2019-08-20 16:42:52 +00:00
|
|
|
// TODO search for old hostCandidates with that target
|
|
|
|
this.hostCandidates.push(hostCandidate);
|
2019-08-20 16:43:15 +00:00
|
|
|
}
|
2019-08-20 16:42:52 +00:00
|
|
|
|
2019-08-22 10:49:29 +00: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-20 16:42:52 +00:00
|
|
|
}
|
|
|
|
|
2019-08-22 10:49:29 +00:00
|
|
|
public async stop () {
|
|
|
|
await this.proxyMasterFunctions.terminateMaster();
|
2019-08-20 16:42:52 +00:00
|
|
|
}
|
2019-08-21 21:41:06 +00:00
|
|
|
|
2019-08-21 21:54:55 +00:00
|
|
|
|
2019-08-20 16:42:52 +00:00
|
|
|
}
|