fix(core): update
This commit is contained in:
parent
4113bf551e
commit
2883d2b926
@ -1,5 +1,7 @@
|
||||
# gitzone ci_default
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
variables:
|
||||
GIT_STRATEGY: clone
|
||||
|
||||
cache:
|
||||
paths:
|
||||
|
@ -9,7 +9,7 @@
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"test": "(tstest test/)",
|
||||
"build": "(tsbuild)",
|
||||
"build": "(tsbuild --web)",
|
||||
"format": "(gitzone format)"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@ -15,7 +15,7 @@ tap.test('should start the testproxy', async () => {
|
||||
await testProxy.start();
|
||||
});
|
||||
|
||||
tap.test('should wait for 5 seconds', async (tools) => {
|
||||
tap.test('should wait for 5 seconds', async tools => {
|
||||
await tools.delayFor(1000);
|
||||
});
|
||||
|
||||
|
@ -47,19 +47,19 @@ export class ProxyWorker {
|
||||
wscConnected.resolve();
|
||||
});
|
||||
|
||||
ws.on('message', async (message) => {
|
||||
ws.on('message', async message => {
|
||||
await wscConnected.promise;
|
||||
wsc.emit('message', message);
|
||||
});
|
||||
wsc.on('message', (message) => {
|
||||
wsc.on('message', message => {
|
||||
ws.emit('message', message);
|
||||
});
|
||||
|
||||
// handle closing
|
||||
ws.on('close', (message) => {
|
||||
ws.on('close', message => {
|
||||
wsc.close();
|
||||
});
|
||||
wsc.on('close', (message) => {
|
||||
wsc.on('close', message => {
|
||||
ws.close();
|
||||
});
|
||||
});
|
||||
|
@ -9,7 +9,9 @@ export class SmartProxy {
|
||||
public proxyWorkerFunctions: plugins.smartspawn.ModuleThread<TProxyWorkerCalls>;
|
||||
public portProxyFunctions: plugins.smartspawn.ModuleThread<TPortProxyCalls>;
|
||||
|
||||
public async updateReversConfigs(reverseConfigsArg: plugins.tsclass.network.IReverseProxyConfig[]) {
|
||||
public async updateReversConfigs(
|
||||
reverseConfigsArg: plugins.tsclass.network.IReverseProxyConfig[]
|
||||
) {
|
||||
// TODO search for old hostCandidates with that target
|
||||
this.reverseConfigs = reverseConfigsArg;
|
||||
if (this.proxyWorkerFunctions) {
|
||||
@ -17,17 +19,21 @@ export class SmartProxy {
|
||||
}
|
||||
}
|
||||
|
||||
public async start () {
|
||||
this.proxyWorkerFunctions = await plugins.smartspawn.spawn<TProxyWorkerCalls>(new plugins.smartspawn.Worker('./smartproxy.classes.proxyworker'));
|
||||
public async start() {
|
||||
this.proxyWorkerFunctions = await plugins.smartspawn.spawn<TProxyWorkerCalls>(
|
||||
new plugins.smartspawn.Worker('./smartproxy.classes.proxyworker')
|
||||
);
|
||||
this.proxyWorkerFunctions.updateReverseConfigs(this.reverseConfigs);
|
||||
|
||||
this.portProxyFunctions = await plugins.smartspawn.spawn<TPortProxyCalls>(new plugins.smartspawn.Worker('./smartproxy.portproxy'));
|
||||
this.portProxyFunctions = await plugins.smartspawn.spawn<TPortProxyCalls>(
|
||||
new plugins.smartspawn.Worker('./smartproxy.portproxy')
|
||||
);
|
||||
await this.proxyWorkerFunctions.start();
|
||||
|
||||
console.log('successfully spawned portproxy and proxyworkers!');
|
||||
}
|
||||
|
||||
public async stop () {
|
||||
public async stop() {
|
||||
await this.proxyWorkerFunctions.stop();
|
||||
await plugins.smartspawn.Thread.terminate(this.portProxyFunctions);
|
||||
console.log('proxy worker stopped');
|
||||
@ -36,6 +42,4 @@ export class SmartProxy {
|
||||
console.log('portproxy stopped');
|
||||
console.log('Terminated all childs!');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -7,9 +7,7 @@ export { http, https };
|
||||
// tsclass scope
|
||||
import * as tsclass from '@tsclass/tsclass';
|
||||
|
||||
export {
|
||||
tsclass
|
||||
};
|
||||
export { tsclass };
|
||||
|
||||
// pushrocks scope
|
||||
import * as smartpromise from '@pushrocks/smartpromise';
|
||||
@ -17,16 +15,9 @@ import * as smartrequest from '@pushrocks/smartrequest';
|
||||
import * as smartspawn from '@pushrocks/smartspawn';
|
||||
import * as smartsystem from '@pushrocks/smartsystem';
|
||||
|
||||
export {
|
||||
smartrequest,
|
||||
smartpromise,
|
||||
smartspawn,
|
||||
smartsystem,
|
||||
};
|
||||
export { smartrequest, smartpromise, smartspawn, smartsystem };
|
||||
|
||||
// third party scope
|
||||
import * as ws from 'ws';
|
||||
|
||||
export {
|
||||
ws
|
||||
};
|
||||
export { ws };
|
||||
|
@ -1,14 +1,16 @@
|
||||
import * as plugins from './smartproxy.plugins';
|
||||
import { expose } from '@pushrocks/smartspawn';
|
||||
import * as net from 'net';
|
||||
const server = net.createServer(from => {
|
||||
const server = net
|
||||
.createServer(from => {
|
||||
const to = net.createConnection({
|
||||
host: 'localhost',
|
||||
port: 8001
|
||||
});
|
||||
from.pipe(to);
|
||||
to.pipe(from);
|
||||
}).listen(8000);
|
||||
})
|
||||
.listen(8000);
|
||||
|
||||
const portProxyCalls = {
|
||||
stop: async () => {
|
||||
|
Loading…
Reference in New Issue
Block a user