fix(core): update

This commit is contained in:
Philipp Kunz 2023-07-27 16:27:50 +02:00
parent 0adb32e7e9
commit 6cdb23ed66
13 changed files with 1691 additions and 1072 deletions

View File

@ -0,0 +1,66 @@
name: Default (not tags)
on:
push:
tags-ignore:
- '**'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Install pnpm and npmci
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
- name: Run npm prepare
run: npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build

View File

@ -0,0 +1,124 @@
name: Default (tags)
on:
push:
tags:
- '*'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build
release:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Release
run: |
npmci node install stable
npmci npm publish
metadata:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
continue-on-error: true
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Code quality
run: |
npmci command npm install -g typescript
npmci npm install
- name: Trigger
run: npmci trigger
- name: Build docs and upload artifacts
run: |
npmci node install stable
npmci npm install
pnpm install -g @gitzone/tsdoc
npmci command tsdoc
continue-on-error: true

View File

@ -1,128 +0,0 @@
# gitzone ci_default
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
cache:
paths:
- .npmci_cache/
key: '$CI_BUILD_STAGE'
stages:
- security
- test
- release
- metadata
before_script:
- npm install -g @shipzone/npmci
# ====================
# security stage
# ====================
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
allow_failure: true
auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci npm prepare
- npmci command npm install --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=dev
tags:
- docker
allow_failure: true
# ====================
# test stage
# ====================
testStable:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
testBuild:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
release:
stage: release
script:
- npmci node install stable
- npmci npm publish
only:
- tags
tags:
- lossless
- docker
- notpriv
# ====================
# metadata stage
# ====================
codequality:
stage: metadata
allow_failure: true
only:
- tags
script:
- npmci command npm install -g typescript
- npmci npm prepare
- npmci npm install
tags:
- lossless
- docker
- priv
trigger:
stage: metadata
script:
- npmci trigger
only:
- tags
tags:
- lossless
- docker
- notpriv
pages:
stage: metadata
script:
- npmci node install stable
- npmci npm prepare
- npmci npm install
- npmci command npm run buildDocs
tags:
- lossless
- docker
- notpriv
only:
- tags
artifacts:
expire_in: 1 week
paths:
- public
allow_failure: true

View File

@ -15,21 +15,21 @@
"buildDocs": "tsdoc" "buildDocs": "tsdoc"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.65", "@gitzone/tsbuild": "^2.1.66",
"@gitzone/tsrun": "^1.2.39", "@gitzone/tsrun": "^1.2.44",
"@gitzone/tstest": "^1.0.73", "@gitzone/tstest": "^1.0.77",
"@pushrocks/tapbundle": "^5.0.4", "@push.rocks/tapbundle": "^5.0.12",
"@types/node": "^18.7.8" "@types/node": "^20.4.5"
}, },
"dependencies": { "dependencies": {
"@pushrocks/lik": "^6.0.0", "@push.rocks/lik": "^6.0.3",
"@pushrocks/smartdelay": "^2.0.13", "@push.rocks/smartdelay": "^3.0.5",
"@pushrocks/smartpromise": "^3.1.7", "@push.rocks/smartpromise": "^4.0.3",
"@pushrocks/smartrequest": "^2.0.10", "@push.rocks/smartrequest": "^2.0.18",
"@pushrocks/smartstring": "^4.0.2", "@push.rocks/smartstring": "^4.0.7",
"@tsclass/tsclass": "^4.0.19", "@tsclass/tsclass": "^4.0.42",
"@types/ws": "^8.5.3", "@types/ws": "^8.5.5",
"ws": "^8.8.1" "ws": "^8.13.0"
}, },
"files": [ "files": [
"ts/**/*", "ts/**/*",

File diff suppressed because it is too large Load Diff

View File

@ -1,27 +1,26 @@
# @pushrocks/smartproxy # @push.rocks/smartproxy
a proxy for handling high workloads of proxying a proxy for handling high workloads of proxying
## Availabililty and Links ## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartproxy) * [npmjs.org (npm package)](https://www.npmjs.com/package/@push.rocks/smartproxy)
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartproxy) * [gitlab.com (source)](https://gitlab.com/push.rocks/smartproxy)
* [github.com (source mirror)](https://github.com/pushrocks/smartproxy) * [github.com (source mirror)](https://github.com/push.rocks/smartproxy)
* [docs (typedoc)](https://pushrocks.gitlab.io/smartproxy/) * [docs (typedoc)](https://push.rocks.gitlab.io/smartproxy/)
## Status for master ## Status for master
Status Category | Status Badge Status Category | Status Badge
-- | -- -- | --
GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/smartproxy/badges/master/pipeline.svg)](https://lossless.cloud) GitLab Pipelines | [![pipeline status](https://gitlab.com/push.rocks/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) GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/push.rocks/smartproxy/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@pushrocks/smartproxy)](https://lossless.cloud) npm | [![npm downloads per month](https://badgen.net/npm/dy/@push.rocks/smartproxy)](https://lossless.cloud)
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/smartproxy)](https://lossless.cloud) Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/push.rocks/smartproxy)](https://lossless.cloud)
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](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/) 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) 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 (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@push.rocks/smartproxy)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/smartproxy)](https://lossless.cloud) PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@push.rocks/smartproxy)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/smartproxy)](https://lossless.cloud) BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@push.rocks/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 ## Usage
@ -35,7 +34,6 @@ We are always happy for code contributions. If you are not the code contributing
For further information read the linked docs at the top of this readme. For further information read the linked docs at the top of this readme.
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh) ## Legal
> MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy) | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)

View File

@ -1,4 +1,4 @@
import { expect, tap } from '@pushrocks/tapbundle'; import { expect, tap } from '@push.rocks/tapbundle';
import * as smartproxy from '../ts/index.js'; import * as smartproxy from '../ts/index.js';
let testProxy: smartproxy.NetworkProxy; let testProxy: smartproxy.NetworkProxy;

View File

@ -2,7 +2,7 @@
* autocreated commitinfo by @pushrocks/commitinfo * autocreated commitinfo by @pushrocks/commitinfo
*/ */
export const commitinfo = { export const commitinfo = {
name: '@pushrocks/smartproxy', name: '@push.rocks/smartproxy',
version: '3.0.58', version: '3.0.59',
description: 'a proxy for handling high workloads of proxying' description: 'a proxy for handling high workloads of proxying'
} }

View File

@ -1,3 +1,3 @@
export * from './smartproxy.classes.networkproxy.js'; export * from './smartproxy.classes.networkproxy.js';
export * from './smartproxy.portproxy.js'; export * from './smartproxy.portproxy.js';
export * from './smartproxy.classes.sslredirect.js' export * from './smartproxy.classes.sslredirect.js';

View File

@ -129,16 +129,20 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
originResponse.writeHead(statusArg, messageArg); originResponse.writeHead(statusArg, messageArg);
originResponse.end(messageArg); originResponse.end(messageArg);
if (originRequest.socket !== originResponse.socket) { if (originRequest.socket !== originResponse.socket) {
console.log('hey, something is strange.') console.log('hey, something is strange.');
} }
originResponse.destroy(); originResponse.destroy();
}; };
console.log(`got request: ${originRequest.headers.host}${plugins.url.parse(originRequest.url).path}`); console.log(
`got request: ${originRequest.headers.host}${plugins.url.parse(originRequest.url).path}`
);
const destinationConfig = this.router.routeReq(originRequest); const destinationConfig = this.router.routeReq(originRequest);
if (!destinationConfig) { if (!destinationConfig) {
console.log(`${originRequest.headers.host} can't be routed properly. Terminating request.`); console.log(
`${originRequest.headers.host} can't be routed properly. Terminating request.`
);
endOriginReqRes(); endOriginReqRes();
return; return;
} }
@ -189,7 +193,7 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
headers: { headers: {
...originRequest.headers, ...originRequest.headers,
'X-Forwarded-Host': originRequest.headers.host, 'X-Forwarded-Host': originRequest.headers.host,
'X-Forwarded-Proto': 'https' 'X-Forwarded-Proto': 'https',
}, },
keepAlive: true, keepAlive: true,
}, },
@ -213,7 +217,7 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
}); });
proxyRequest.on('error', () => { proxyRequest.on('error', () => {
endOriginReqRes(); endOriginReqRes();
}) });
} }
); );
originResponse.statusCode = proxyResponse.statusCode; originResponse.statusCode = proxyResponse.statusCode;
@ -238,58 +242,65 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
}); });
proxyResponse.on('timeout', () => { proxyResponse.on('timeout', () => {
originResponse.end(); originResponse.end();
originResponse.destroy() originResponse.destroy();
}); });
} }
); );
// Enable websockets // Enable websockets
const wsServer = new plugins.ws.WebSocketServer({ server: this.httpsServer }); const wsServer = new plugins.ws.WebSocketServer({ server: this.httpsServer });
wsServer.on('connection', async (wsIncoming: plugins.wsDefault, reqArg: plugins.http.IncomingMessage) => { wsServer.on(
console.log(`wss proxy: got connection for wsc for https://${reqArg.headers.host}${reqArg.url}`); 'connection',
async (wsIncoming: plugins.wsDefault, reqArg: plugins.http.IncomingMessage) => {
let wsOutgoing: plugins.wsDefault; console.log(
`wss proxy: got connection for wsc for https://${reqArg.headers.host}${reqArg.url}`
);
const outGoingDeferred = plugins.smartpromise.defer(); let wsOutgoing: plugins.wsDefault;
try { const outGoingDeferred = plugins.smartpromise.defer();
wsOutgoing = new plugins.wsDefault(`ws://${this.router.routeReq(reqArg).destinationIp}:${this.router.routeReq(reqArg).destinationPort}${reqArg.url}`);
console.log('wss proxy: initiated outgoing proxy'); try {
wsOutgoing.on('open', async () => { wsOutgoing = new plugins.wsDefault(
outGoingDeferred.resolve(); `ws://${this.router.routeReq(reqArg).destinationIp}:${
}) this.router.routeReq(reqArg).destinationPort
} catch (err) { }${reqArg.url}`
console.log(err); );
wsIncoming.terminate(); console.log('wss proxy: initiated outgoing proxy');
return; wsOutgoing.on('open', async () => {
outGoingDeferred.resolve();
});
} catch (err) {
console.log(err);
wsIncoming.terminate();
return;
}
wsIncoming.on('message', async (message, isBinary) => {
await outGoingDeferred.promise;
// console.log("client to upstream", message);
wsOutgoing.send(message, { binary: isBinary });
});
wsOutgoing.on('message', async (message, isBinary) => {
// console.log("upstream to client", message);
wsIncoming.send(message, { binary: isBinary });
});
const terminateWsOutgoing = () => {
wsOutgoing.terminate();
console.log('terminated outgoing ws.');
};
wsIncoming.on('error', () => terminateWsOutgoing());
wsIncoming.on('close', () => terminateWsOutgoing());
const terminateWsIncoming = () => {
wsIncoming.terminate();
console.log('terminated incoming ws.');
};
wsOutgoing.on('error', () => terminateWsIncoming());
wsOutgoing.on('close', () => terminateWsIncoming());
} }
);
wsIncoming.on("message", async (message, isBinary) => {
await outGoingDeferred.promise;
// console.log("client to upstream", message);
wsOutgoing.send(message, { binary: isBinary });
});
wsOutgoing.on("message", async (message, isBinary) => {
// console.log("upstream to client", message);
wsIncoming.send(message, { binary: isBinary });
});
const terminateWsOutgoing = () => {
wsOutgoing.terminate();
console.log('terminated outgoing ws.');
}
wsIncoming.on("error", () => terminateWsOutgoing());
wsIncoming.on("close", () => terminateWsOutgoing());
const terminateWsIncoming = () => {
wsIncoming.terminate();
console.log('terminated incoming ws.');
}
wsOutgoing.on("error", () => terminateWsIncoming());
wsOutgoing.on("close", () => terminateWsIncoming());
});
this.httpsServer.keepAliveTimeout = 600 * 1000; this.httpsServer.keepAliveTimeout = 600 * 1000;
this.httpsServer.headersTimeout = 600 * 1000; this.httpsServer.headersTimeout = 600 * 1000;
@ -314,7 +325,7 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
}); });
connection.on('timeout', () => { connection.on('timeout', () => {
cleanupConnection(); cleanupConnection();
}) });
}); });
this.httpsServer.listen(this.options.port); this.httpsServer.listen(this.options.port);

View File

@ -29,4 +29,4 @@ export class SslRedirect {
}); });
await done.promise; await done.promise;
} }
} }

View File

@ -12,11 +12,11 @@ import * as tsclass from '@tsclass/tsclass';
export { tsclass }; export { tsclass };
// pushrocks scope // pushrocks scope
import * as lik from '@pushrocks/lik'; import * as lik from '@push.rocks/lik';
import * as smartdelay from '@pushrocks/smartdelay'; import * as smartdelay from '@push.rocks/smartdelay';
import * as smartpromise from '@pushrocks/smartpromise'; import * as smartpromise from '@push.rocks/smartpromise';
import * as smartrequest from '@pushrocks/smartrequest'; import * as smartrequest from '@push.rocks/smartrequest';
import * as smartstring from '@pushrocks/smartstring'; import * as smartstring from '@push.rocks/smartstring';
export { lik, smartdelay, smartrequest, smartpromise, smartstring }; export { lik, smartdelay, smartrequest, smartpromise, smartstring };

View File

@ -5,6 +5,7 @@
"target": "ES2022", "target": "ES2022",
"module": "ES2022", "module": "ES2022",
"moduleResolution": "nodenext", "moduleResolution": "nodenext",
"esModuleInterop": true "esModuleInterop": true,
"verbatimModuleSyntax": true,
} }
} }