fix(core): update
This commit is contained in:
parent
3b2d140836
commit
736113eb4e
@ -12,7 +12,7 @@ tap.test('should start the testproxy', async () => {
|
||||
});
|
||||
|
||||
tap.test('should supply reverse proxy config', async () => {
|
||||
testProxy.updateReversConfigs([
|
||||
testProxy.updateReverseConfigs([
|
||||
{
|
||||
destinationIp: 'localhost',
|
||||
destinationPort: '3000',
|
||||
|
@ -2,9 +2,23 @@ import * as plugins from './smartproxy.plugins';
|
||||
import { expose } from '@pushrocks/smartspawn';
|
||||
import * as net from 'net';
|
||||
let netServer: plugins.net.Server;
|
||||
let httpServer: plugins.http.Server;
|
||||
|
||||
const portProxyCalls = {
|
||||
start: async (portArg = 8000) => {
|
||||
httpServer = plugins.http.createServer((request, response) => {
|
||||
|
||||
const requestUrl = new URL(request.url, `http://${request.headers.host}`);
|
||||
const completeUrlWithoutProtocol = `${requestUrl.host}${requestUrl.pathname}${requestUrl.search}`;
|
||||
const redirectUrl = `https://${completeUrlWithoutProtocol}`;
|
||||
console.log(`Got http request for http://${completeUrlWithoutProtocol}`);
|
||||
console.log(`Redirecting to ${redirectUrl}`);
|
||||
response.writeHead(302, {
|
||||
'Location': redirectUrl
|
||||
});
|
||||
response.end();
|
||||
});
|
||||
httpServer.listen(7999);
|
||||
netServer = net
|
||||
.createServer(from => {
|
||||
const to = net.createConnection({
|
||||
@ -19,8 +33,10 @@ const portProxyCalls = {
|
||||
},
|
||||
stop: async () => {
|
||||
const done = plugins.smartpromise.defer();
|
||||
netServer.close(() => {
|
||||
done.resolve();
|
||||
httpServer.close(() => {
|
||||
netServer.close(() => {
|
||||
done.resolve();
|
||||
});
|
||||
});
|
||||
await done.promise;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user