fix(core): update

This commit is contained in:
Philipp Kunz 2019-08-22 16:14:50 +02:00
parent 4113bf551e
commit 2883d2b926
7 changed files with 35 additions and 36 deletions

View File

@ -1,5 +1,7 @@
# gitzone ci_default
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
variables:
GIT_STRATEGY: clone
cache:
paths:

View File

@ -9,7 +9,7 @@
"license": "MIT",
"scripts": {
"test": "(tstest test/)",
"build": "(tsbuild)",
"build": "(tsbuild --web)",
"format": "(gitzone format)"
},
"devDependencies": {

View File

@ -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);
});

View File

@ -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();
});
});

View File

@ -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) {
@ -18,10 +20,14 @@ export class SmartProxy {
}
public async start() {
this.proxyWorkerFunctions = await plugins.smartspawn.spawn<TProxyWorkerCalls>(new plugins.smartspawn.Worker('./smartproxy.classes.proxyworker'));
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!');
@ -36,6 +42,4 @@ export class SmartProxy {
console.log('portproxy stopped');
console.log('Terminated all childs!');
}
}

View File

@ -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 };

View File

@ -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 () => {