fix(core): update
This commit is contained in:
parent
ef7e54be34
commit
df001e13f3
4
.gitignore
vendored
4
.gitignore
vendored
@ -15,8 +15,6 @@ node_modules/
|
||||
|
||||
# builds
|
||||
dist/
|
||||
dist_web/
|
||||
dist_serve/
|
||||
dist_ts_web/
|
||||
dist_*/
|
||||
|
||||
# custom
|
@ -19,22 +19,35 @@ mirror:
|
||||
stage: security
|
||||
script:
|
||||
- npmci git mirror
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
snyk:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:snyk
|
||||
auditProductionDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install --production --ignore-scripts
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command npm audit --audit-level=high --only=prod --production
|
||||
tags:
|
||||
- docker
|
||||
|
||||
auditDevDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install --ignore-scripts
|
||||
- npmci command snyk test
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command npm audit --audit-level=high --only=dev
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
allow_failure: true
|
||||
|
||||
# ====================
|
||||
# test stage
|
||||
@ -49,9 +62,7 @@ testStable:
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- priv
|
||||
|
||||
testBuild:
|
||||
stage: test
|
||||
@ -62,9 +73,7 @@ testBuild:
|
||||
- npmci command npm run build
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
release:
|
||||
stage: release
|
||||
@ -84,6 +93,8 @@ release:
|
||||
codequality:
|
||||
stage: metadata
|
||||
allow_failure: true
|
||||
only:
|
||||
- tags
|
||||
script:
|
||||
- npmci command npm install -g tslint typescript
|
||||
- npmci npm prepare
|
||||
|
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -15,7 +15,7 @@
|
||||
"properties": {
|
||||
"projectType": {
|
||||
"type": "string",
|
||||
"enum": ["website", "element", "service", "npm"]
|
||||
"enum": ["website", "element", "service", "npm", "wcc"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
10462
package-lock.json
generated
10462
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
36
package.json
36
package.json
@ -3,8 +3,8 @@
|
||||
"version": "2.0.3",
|
||||
"private": false,
|
||||
"description": "a proxy for handling high workloads of proxying",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
"author": "Lossless GmbH",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
@ -13,34 +13,38 @@
|
||||
"format": "(gitzone format)"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.17",
|
||||
"@gitzone/tstest": "^1.0.28",
|
||||
"@pushrocks/tapbundle": "^3.2.0",
|
||||
"@types/node": "^13.7.4",
|
||||
"tslint": "^6.0.0",
|
||||
"@gitzone/tsbuild": "^2.1.25",
|
||||
"@gitzone/tstest": "^1.0.52",
|
||||
"@pushrocks/tapbundle": "^3.2.10",
|
||||
"@types/node": "^14.14.22",
|
||||
"tslint": "^6.1.3",
|
||||
"tslint-config-prettier": "^1.15.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pushrocks/lik": "^3.0.19",
|
||||
"@pushrocks/smartnetwork": "^1.1.18",
|
||||
"@pushrocks/smartpromise": "^3.0.6",
|
||||
"@pushrocks/smartrequest": "^1.1.47",
|
||||
"@pushrocks/lik": "^4.0.20",
|
||||
"@pushrocks/smartnetwork": "^1.1.22",
|
||||
"@pushrocks/smartpromise": "^3.1.3",
|
||||
"@pushrocks/smartrequest": "^1.1.51",
|
||||
"@pushrocks/smartspawn": "^2.0.9",
|
||||
"@pushrocks/smartstring": "^3.0.18",
|
||||
"@pushrocks/smartstring": "^3.0.24",
|
||||
"@pushrocks/smartsystem": "^2.0.9",
|
||||
"@tsclass/tsclass": "^3.0.10",
|
||||
"@types/ws": "^7.2.1",
|
||||
"ws": "^7.2.1"
|
||||
"@tsclass/tsclass": "^3.0.29",
|
||||
"@types/ws": "^7.4.0",
|
||||
"ws": "^7.4.2"
|
||||
},
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
"ts_web/**/*",
|
||||
"dist/**/*",
|
||||
"dist_web/**/*",
|
||||
"dist_*/**/*",
|
||||
"dist_ts/**/*",
|
||||
"dist_ts_web/**/*",
|
||||
"assets/**/*",
|
||||
"cli.js",
|
||||
"npmextra.json",
|
||||
"readme.md"
|
||||
],
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
]
|
||||
}
|
||||
|
22
readme.md
22
readme.md
@ -8,13 +8,20 @@ a proxy for handling high workloads of proxying
|
||||
* [docs (typedoc)](https://pushrocks.gitlab.io/smartproxy/)
|
||||
|
||||
## Status for master
|
||||
[![pipeline status](https://gitlab.com/pushrocks/smartproxy/badges/master/pipeline.svg)](https://gitlab.com/pushrocks/smartproxy/commits/master)
|
||||
[![coverage report](https://gitlab.com/pushrocks/smartproxy/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartproxy/commits/master)
|
||||
[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartproxy.svg)](https://www.npmjs.com/package/@pushrocks/smartproxy)
|
||||
[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartproxy/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartproxy)
|
||||
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/)
|
||||
|
||||
Status Category | Status Badge
|
||||
-- | --
|
||||
GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/smartproxy/badges/master/pipeline.svg)](https://lossless.cloud)
|
||||
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/smartproxy/badges/master/coverage.svg)](https://lossless.cloud)
|
||||
npm | [![npm downloads per month](https://badgen.net/npm/dy/@pushrocks/smartproxy)](https://lossless.cloud)
|
||||
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/smartproxy)](https://lossless.cloud)
|
||||
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
|
||||
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
|
||||
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@pushrocks/smartproxy)](https://lossless.cloud)
|
||||
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/smartproxy)](https://lossless.cloud)
|
||||
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/smartproxy)](https://lossless.cloud)
|
||||
Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud)
|
||||
|
||||
## Usage
|
||||
|
||||
@ -22,7 +29,6 @@ a proxy for handling high workloads of proxying
|
||||
|
||||
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
|
||||
|
||||
|
||||
## Contribution
|
||||
|
||||
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
|
||||
|
@ -97,12 +97,12 @@ TzJTbTCteOUUJTrcfZ0gGhGkF4nYLmX5OI+TPqrDJf0fZ+mzAEHzDDVXcBYpYRDr
|
||||
r8d9QwrK+WaqVi2ofbMfMByVF72jgeJNa4nxwT9bVbu/Q1T2Lt+YPb4pQ7yCoUgS
|
||||
JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
|
||||
-----END CERTIFICATE-----
|
||||
`
|
||||
}
|
||||
`,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
tap.test('should wait for 60 seconds', async tools => {
|
||||
tap.test('should wait for 60 seconds', async (tools) => {
|
||||
await tools.delayFor(10000);
|
||||
});
|
||||
|
||||
|
@ -7,7 +7,7 @@ export class ProxyWorker {
|
||||
public httpsServer: plugins.https.Server; // | plugins.http.Server;
|
||||
public port = 8001;
|
||||
public router = new SmartproxyRouter();
|
||||
public socketMap = new plugins.lik.Objectmap<plugins.net.Socket>();
|
||||
public socketMap = new plugins.lik.ObjectMap<plugins.net.Socket>();
|
||||
|
||||
/**
|
||||
* starts the proxyInstance
|
||||
@ -101,7 +101,7 @@ TzJTbTCteOUUJTrcfZ0gGhGkF4nYLmX5OI+TPqrDJf0fZ+mzAEHzDDVXcBYpYRDr
|
||||
r8d9QwrK+WaqVi2ofbMfMByVF72jgeJNa4nxwT9bVbu/Q1T2Lt+YPb4pQ7yCoUgS
|
||||
JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
|
||||
-----END CERTIFICATE-----
|
||||
`
|
||||
`,
|
||||
},
|
||||
async (req, res) => {
|
||||
console.log('got request');
|
||||
@ -126,7 +126,7 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
|
||||
if (authHeader) {
|
||||
if (!authHeader.includes('Basic ')) {
|
||||
return endRequest(401, 'Authentication required', {
|
||||
'WWW-Authenticate': 'Basic realm="Access to the staging site", charset="UTF-8"'
|
||||
'WWW-Authenticate': 'Basic realm="Access to the staging site", charset="UTF-8"',
|
||||
});
|
||||
}
|
||||
const authStringBase64 = req.headers.authorization.replace('Basic ', '');
|
||||
@ -160,14 +160,14 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
|
||||
destinationUrl,
|
||||
{
|
||||
method: req.method,
|
||||
headers: req.headers
|
||||
headers: req.headers,
|
||||
},
|
||||
true, // lets make this streaming
|
||||
request => {
|
||||
req.on('data', data => {
|
||||
(request) => {
|
||||
req.on('data', (data) => {
|
||||
request.write(data);
|
||||
});
|
||||
req.on('end', data => {
|
||||
req.on('end', (data) => {
|
||||
request.end();
|
||||
});
|
||||
}
|
||||
@ -177,7 +177,7 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
|
||||
for (const header of Object.keys(response.headers)) {
|
||||
res.setHeader(header, response.headers[header]);
|
||||
}
|
||||
response.on('data', data => {
|
||||
response.on('data', (data) => {
|
||||
res.write(data);
|
||||
});
|
||||
response.on('end', () => {
|
||||
@ -194,33 +194,33 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
|
||||
|
||||
const wsc = new plugins.wsDefault(this.router.routeWs(ws), {
|
||||
headers: {
|
||||
Host: ws.url
|
||||
}
|
||||
Host: ws.url,
|
||||
},
|
||||
});
|
||||
wsc.on('open', () => {
|
||||
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();
|
||||
});
|
||||
});
|
||||
this.httpsServer.keepAliveTimeout = 61000;
|
||||
this.httpsServer.headersTimeout = 65000;
|
||||
|
||||
this.httpsServer.on('connection', connection => {
|
||||
this.httpsServer.on('connection', (connection) => {
|
||||
this.socketMap.add(connection);
|
||||
connection.on('close', () => {
|
||||
this.socketMap.remove(connection);
|
||||
@ -238,7 +238,7 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
|
||||
// console.log(hostCandidate);
|
||||
this.httpsServer.addContext(hostCandidate.hostName, {
|
||||
cert: hostCandidate.publicKey,
|
||||
key: hostCandidate.privateKey
|
||||
key: hostCandidate.privateKey,
|
||||
});
|
||||
}
|
||||
/* this.httpsServer.close();
|
||||
@ -250,7 +250,7 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
|
||||
this.httpsServer.close(() => {
|
||||
done.resolve();
|
||||
});
|
||||
await this.socketMap.forEach(async socket => {
|
||||
await this.socketMap.forEach(async (socket) => {
|
||||
socket.destroy();
|
||||
});
|
||||
await done.promise;
|
||||
@ -269,7 +269,7 @@ const proxyWorkerCalls = {
|
||||
},
|
||||
updateReverseConfigs: async (configArray: plugins.tsclass.network.IReverseProxyConfig[]) => {
|
||||
await proxyWorkerInstance.updateProxyConfigs(configArray);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export type TProxyWorkerCalls = typeof proxyWorkerCalls;
|
||||
|
@ -16,7 +16,7 @@ export class SmartproxyRouter {
|
||||
*/
|
||||
public routeReq(req: plugins.http.IncomingMessage): plugins.tsclass.network.IReverseProxyConfig {
|
||||
const originalHost = req.headers.host;
|
||||
const correspodingReverseProxyConfig = this.reverseProxyConfigs.find(reverseConfig => {
|
||||
const correspodingReverseProxyConfig = this.reverseProxyConfigs.find((reverseConfig) => {
|
||||
return reverseConfig.hostName === originalHost;
|
||||
});
|
||||
return correspodingReverseProxyConfig;
|
||||
@ -24,7 +24,7 @@ export class SmartproxyRouter {
|
||||
|
||||
public routeWs(ws: plugins.wsDefault) {
|
||||
const originalHost = plugins.url.parse(ws.url).host;
|
||||
const correspodingReverseProxyConfig = this.reverseProxyConfigs.find(reverseConfig => {
|
||||
const correspodingReverseProxyConfig = this.reverseProxyConfigs.find((reverseConfig) => {
|
||||
return reverseConfig.hostName === originalHost;
|
||||
});
|
||||
return correspodingReverseProxyConfig.destinationIp;
|
||||
|
@ -13,24 +13,28 @@ const portProxyCalls = {
|
||||
console.log(`Got http request for http://${completeUrlWithoutProtocol}`);
|
||||
console.log(`Redirecting to ${redirectUrl}`);
|
||||
response.writeHead(302, {
|
||||
Location: redirectUrl
|
||||
Location: redirectUrl,
|
||||
});
|
||||
response.end();
|
||||
});
|
||||
httpServer.listen(7999);
|
||||
netServer = net
|
||||
.createServer(from => {
|
||||
.createServer((from) => {
|
||||
const to = net.createConnection({
|
||||
host: 'localhost',
|
||||
port: 8001
|
||||
port: 8001,
|
||||
});
|
||||
from.pipe(to);
|
||||
to.pipe(from);
|
||||
from.on('error', () => {
|
||||
from.end(), to.end();
|
||||
});
|
||||
to.on('error', () => {
|
||||
from.end(), to.end();
|
||||
});
|
||||
from.pipe(to)
|
||||
to.pipe(from)
|
||||
from.on('error', () => { from.end(), to.end() });
|
||||
to.on('error', () => { from.end(), to.end() });
|
||||
from.on('close', () => {
|
||||
to.end();
|
||||
})
|
||||
});
|
||||
})
|
||||
.listen(portArg);
|
||||
console.log(`PortProxy -> OK: Now listening on port ${portArg}`);
|
||||
@ -43,7 +47,7 @@ const portProxyCalls = {
|
||||
});
|
||||
});
|
||||
await done.promise;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export type TPortProxyCalls = typeof portProxyCalls;
|
||||
|
Loading…
Reference in New Issue
Block a user