Compare commits

...

148 Commits

Author SHA1 Message Date
f114968298 3.0.60 2023-07-27 16:28:26 +02:00
def6644e80 fix(core): update 2023-07-27 16:28:26 +02:00
c85f3da924 3.0.59 2023-07-27 16:27:51 +02:00
6cdb23ed66 fix(core): update 2023-07-27 16:27:50 +02:00
0adb32e7e9 switch to new org scheme 2023-07-11 01:25:18 +02:00
5d65e1668b switch to new org scheme 2023-07-10 10:17:33 +02:00
632015a7bd 3.0.58 2023-02-04 19:32:14 +01:00
972ee2af54 fix(core): update 2023-02-04 19:32:13 +01:00
9b1ff5eed8 3.0.57 2023-01-06 13:04:12 +01:00
0739d1093a fix(core): update 2023-01-06 13:04:11 +01:00
ee4f7fc48d 3.0.56 2023-01-06 13:00:11 +01:00
f6e656361b fix(core): update 2023-01-06 13:00:10 +01:00
e51c2a88cc 3.0.55 2023-01-06 12:56:51 +01:00
7f8112930d fix(core): update 2023-01-06 12:56:51 +01:00
b5c83b5c75 3.0.54 2023-01-06 12:53:58 +01:00
63ce1a44a4 fix(core): update 2023-01-06 12:53:58 +01:00
759f70b84d 3.0.53 2023-01-06 11:57:11 +01:00
45ce56b118 fix(core): update 2023-01-06 11:57:11 +01:00
0cc7184e58 3.0.52 2023-01-05 20:15:17 +01:00
392e241208 fix(core): update 2023-01-05 20:15:16 +01:00
32c6d77178 3.0.51 2023-01-05 19:33:16 +01:00
2c4316d2d3 fix(core): update 2023-01-05 19:33:15 +01:00
62e6387c1d 3.0.50 2023-01-05 19:21:03 +01:00
7fe22e962a fix(core): update 2023-01-05 19:21:02 +01:00
3f1f718308 3.0.49 2023-01-05 18:31:55 +01:00
ce94d283c1 fix(core): update 2023-01-05 18:31:55 +01:00
a1c4f3c341 3.0.48 2023-01-05 18:05:36 +01:00
8087bab197 fix(core): update 2023-01-05 18:05:36 +01:00
db63e7bf79 3.0.47 2023-01-05 18:00:51 +01:00
2615a0ebd4 fix(core): update 2023-01-05 18:00:50 +01:00
d5d77af98d 3.0.46 2023-01-05 17:28:55 +01:00
1f1bf77807 fix(core): update 2023-01-05 17:28:54 +01:00
d4269d290d 3.0.45 2023-01-05 17:21:42 +01:00
e05e5ede55 fix(core): update 2023-01-05 17:21:41 +01:00
b6c7f13baa 3.0.44 2023-01-05 17:00:32 +01:00
055d328bd0 fix(core): update 2023-01-05 17:00:31 +01:00
20b9a220fc 3.0.43 2023-01-05 15:53:17 +01:00
2170fe3518 fix(core): update 2023-01-05 15:53:17 +01:00
04b13e53b9 3.0.42 2023-01-05 15:26:36 +01:00
f1a4fae704 fix(core): update 2023-01-05 15:26:36 +01:00
5ee5147606 3.0.41 2023-01-05 14:57:55 +01:00
748c6e14e4 fix(core): update 2023-01-05 14:57:54 +01:00
f018957de4 3.0.40 2023-01-04 15:59:59 +01:00
a6583b037c fix(core): update 2023-01-04 15:59:58 +01:00
3ab4144c9a 3.0.39 2023-01-04 15:59:32 +01:00
0d2885ace4 fix(core): update 2023-01-04 15:59:31 +01:00
1723275215 3.0.38 2022-08-06 22:42:05 +02:00
977d8b0310 fix(core): update 2022-08-06 22:42:05 +02:00
5bb065f82b 3.0.37 2022-08-04 17:16:27 +02:00
942b812f97 fix(core): update 2022-08-04 17:16:26 +02:00
59a025b308 3.0.36 2022-08-04 14:21:06 +02:00
458e7d6b58 fix(core): update 2022-08-04 14:21:05 +02:00
7b0f824d29 3.0.35 2022-08-01 18:40:45 +02:00
b5796b86d5 fix(core): update 2022-08-01 18:40:44 +02:00
1f8ea59221 3.0.34 2022-08-01 13:00:47 +02:00
d717568572 fix(core): update 2022-08-01 13:00:46 +02:00
28d050851f 3.0.33 2022-08-01 12:56:15 +02:00
acbd109985 fix(core): update 2022-08-01 12:56:14 +02:00
cc38a6d10e 3.0.32 2022-08-01 12:55:01 +02:00
748b07efe2 fix(core): update 2022-08-01 12:55:00 +02:00
be4fd0978a 3.0.31 2022-08-01 12:31:30 +02:00
4521010b82 fix(core): update 2022-08-01 12:31:29 +02:00
bd1f1a4c1c 3.0.30 2022-07-31 08:30:13 +02:00
d3bdd56660 fix(core): update 2022-07-31 08:30:13 +02:00
c38a7c4c32 3.0.29 2022-07-30 23:00:23 +02:00
858628196a fix(core): update 2022-07-30 23:00:23 +02:00
4910679058 3.0.28 2022-07-30 23:00:15 +02:00
97db2012ca fix(core): update 2022-07-30 23:00:15 +02:00
0ee13b4e06 3.0.27 2022-07-30 22:40:08 +02:00
21f5882fa3 fix(core): update 2022-07-30 22:40:08 +02:00
48b43f9f0d 3.0.26 2022-07-30 22:29:31 +02:00
d3d476fd53 fix(core): update 2022-07-30 22:29:31 +02:00
b80b8a0a20 3.0.25 2022-07-30 22:20:31 +02:00
384943f697 fix(core): update 2022-07-30 22:20:31 +02:00
e9239ed978 3.0.24 2022-07-30 21:29:35 +02:00
baf1844866 fix(core): update 2022-07-30 21:29:34 +02:00
0b3d7f8a06 3.0.23 2022-07-30 21:28:08 +02:00
c38a2745e9 fix(core): update 2022-07-30 21:28:08 +02:00
a0f39d1c5b 3.0.22 2022-07-30 21:25:27 +02:00
c67ac868a5 fix(core): update 2022-07-30 21:25:27 +02:00
90e1a0453e 3.0.21 2022-07-30 19:28:24 +02:00
d7765fb5dc fix(core): update 2022-07-30 19:28:23 +02:00
0fdd17b430 3.0.20 2022-07-30 18:53:21 +02:00
0562de6aa1 fix(core): update 2022-07-30 18:53:21 +02:00
7b550a35aa 3.0.19 2022-07-30 18:49:14 +02:00
fb66aac6e7 fix(core): update 2022-07-30 18:49:14 +02:00
208790cfcf 3.0.18 2022-07-30 18:29:21 +02:00
5978bbaf66 fix(core): update 2022-07-30 18:29:20 +02:00
1c47eafe5f 3.0.17 2022-07-30 17:32:59 +02:00
69e3a71354 fix(core): update 2022-07-30 17:32:58 +02:00
21e92bf0c1 3.0.16 2022-07-30 17:26:36 +02:00
d732e6e7aa fix(core): update 2022-07-30 17:26:35 +02:00
5fdfcdb407 3.0.15 2022-07-30 13:30:25 +02:00
49e2e90bda fix(core): update 2022-07-30 13:30:25 +02:00
b8e53e7b42 3.0.14 2022-07-30 08:20:21 +02:00
1136841b3d fix(core): update 2022-07-30 08:20:20 +02:00
42cbc51d22 3.0.13 2022-07-30 02:07:32 +02:00
2d16403ad1 fix(core): update 2022-07-30 02:07:31 +02:00
afe847499a 3.0.12 2022-07-30 01:57:42 +02:00
f980bb70b4 fix(core): update 2022-07-30 01:57:42 +02:00
f192a8f041 3.0.11 2022-07-29 16:12:18 +02:00
64bf3aef6d fix(core): update 2022-07-29 16:12:18 +02:00
a5e3cbd05b 3.0.10 2022-07-29 15:26:03 +02:00
2f0fad999a fix(core): update 2022-07-29 15:26:02 +02:00
5e6477720d 3.0.9 2022-07-29 15:22:32 +02:00
bad8bf0688 fix(core): update 2022-07-29 15:22:31 +02:00
4f1db106fb 3.0.8 2022-07-29 04:25:01 +02:00
d47829a8b2 fix(core): update 2022-07-29 04:25:01 +02:00
ca55d06244 3.0.7 2022-07-29 03:39:05 +02:00
7284924b26 fix(core): update 2022-07-29 03:39:05 +02:00
10857aa12b 3.0.6 2022-07-29 02:30:15 +02:00
c968c7f844 fix(core): update 2022-07-29 02:30:15 +02:00
b07015f6c4 3.0.5 2022-07-29 01:52:34 +02:00
ca4ddade17 fix(core): update 2022-07-29 01:52:34 +02:00
17eaea4124 3.0.4 2022-07-29 01:37:47 +02:00
d3d8f6ff57 fix(core): update 2022-07-29 01:37:47 +02:00
906661c7f4 3.0.3 2022-07-29 01:31:52 +02:00
ea46caebb7 fix(core): update 2022-07-29 01:31:52 +02:00
973e896fbf 3.0.2 2022-07-29 01:26:52 +02:00
4605035b01 fix(core): update 2022-07-29 01:26:51 +02:00
1e4e2c4ab6 3.0.1 2022-07-29 01:23:18 +02:00
30896b045f fix(core): update 2022-07-29 01:23:17 +02:00
08f382b9fa 3.0.0 2022-07-29 00:50:31 +02:00
1629dc1f5a BREAKING CHANGE(core): switch to esm 2022-07-29 00:50:30 +02:00
b33acdea41 2.0.16 2022-07-29 00:49:47 +02:00
101470dcd4 fix(core): update 2022-07-29 00:49:46 +02:00
ca73849541 2.0.15 2021-02-03 19:42:27 +00:00
b64523b0b2 fix(core): update 2021-02-03 19:42:27 +00:00
963ad6efa4 2.0.14 2021-02-03 15:11:55 +00:00
d271029302 fix(core): update 2021-02-03 15:11:55 +00:00
018fcbf71e 2.0.13 2021-02-03 11:19:57 +00:00
fa04732241 fix(core): update 2021-02-03 11:19:56 +00:00
da19fab8d8 2.0.12 2021-02-03 11:02:26 +00:00
8d318dca28 fix(core): update 2021-02-03 11:02:26 +00:00
d03bfcc793 2.0.11 2021-02-03 01:14:10 +00:00
4ba2686977 fix(core): update 2021-02-03 01:14:09 +00:00
d24c4d4b7a 2.0.10 2021-02-03 00:30:35 +00:00
e1d4d6cf38 fix(core): update 2021-02-03 00:30:35 +00:00
11344ac0df 2.0.9 2021-02-03 00:23:29 +00:00
85fcfc3c36 fix(core): update 2021-02-03 00:23:28 +00:00
e9ac7b2347 2.0.8 2021-02-03 00:16:11 +00:00
2c59540768 fix(core): update 2021-02-03 00:16:11 +00:00
0f82d63f5c 2.0.7 2021-02-03 00:13:30 +00:00
b5fcdadd3d fix(core): update 2021-02-03 00:13:29 +00:00
6168b07414 2.0.6 2021-02-02 21:59:55 +00:00
588179335a fix(core): update 2021-02-02 21:59:54 +00:00
703cbedad4 2.0.5 2021-02-02 21:59:25 +00:00
dd7e9e8416 fix(core): update 2021-02-02 21:59:24 +00:00
20 changed files with 5453 additions and 11973 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,137 +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
# ====================
# security stage
# ====================
mirror:
stage: security
script:
- npmci git mirror
only:
- tags
tags:
- lossless
- docker
- notpriv
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 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 tslint typescript
- npmci npm prepare
- npmci npm install
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
tags:
- lossless
- docker
- priv
trigger:
stage: metadata
script:
- npmci trigger
only:
- tags
tags:
- lossless
- docker
- notpriv
pages:
stage: metadata
script:
- npmci node install lts
- npmci command npm install -g @gitzone/tsdoc
- npmci npm prepare
- npmci npm install
- npmci command tsdoc
tags:
- lossless
- docker
- notpriv
only:
- tags
artifacts:
expire_in: 1 week
paths:
- public
allow_failure: true

24
.vscode/launch.json vendored
View File

@ -2,28 +2,10 @@
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "configurations": [
{ {
"name": "current file", "command": "npm test",
"type": "node", "name": "Run npm test",
"request": "launch", "request": "launch",
"args": [ "type": "node-terminal"
"${relativeFile}"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": "test.ts",
"type": "node",
"request": "launch",
"args": [
"test/test.ts"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
} }
] ]
} }

View File

@ -3,10 +3,10 @@
"projectType": "npm", "projectType": "npm",
"module": { "module": {
"githost": "gitlab.com", "githost": "gitlab.com",
"gitscope": "pushrocks", "gitscope": "push.rocks",
"gitrepo": "smartproxy", "gitrepo": "smartproxy",
"shortDescription": "a proxy for handling high workloads of proxying", "description": "a proxy for handling high workloads of proxying",
"npmPackagename": "@pushrocks/smartproxy", "npmPackagename": "@push.rocks/smartproxy",
"license": "MIT", "license": "MIT",
"projectDomain": "push.rocks" "projectDomain": "push.rocks"
} }

11548
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,36 +1,35 @@
{ {
"name": "@pushrocks/smartproxy", "name": "@push.rocks/smartproxy",
"version": "2.0.4", "version": "3.0.60",
"private": false, "private": false,
"description": "a proxy for handling high workloads of proxying", "description": "a proxy for handling high workloads of proxying",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts", "typings": "dist_ts/index.d.ts",
"type": "module",
"author": "Lossless GmbH", "author": "Lossless GmbH",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"test": "(tstest test/)", "test": "(tstest test/)",
"build": "(tsbuild --web)", "build": "(tsbuild --web --allowimplicitany)",
"format": "(gitzone format)" "format": "(gitzone format)",
"buildDocs": "tsdoc"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.25", "@gitzone/tsbuild": "^2.1.66",
"@gitzone/tstest": "^1.0.52", "@gitzone/tsrun": "^1.2.44",
"@pushrocks/tapbundle": "^3.2.10", "@gitzone/tstest": "^1.0.77",
"@types/node": "^14.14.22", "@push.rocks/tapbundle": "^5.0.12",
"tslint": "^6.1.3", "@types/node": "^20.4.5"
"tslint-config-prettier": "^1.15.0"
}, },
"dependencies": { "dependencies": {
"@pushrocks/lik": "^4.0.20", "@push.rocks/lik": "^6.0.3",
"@pushrocks/smartnetwork": "^1.1.22", "@push.rocks/smartdelay": "^3.0.5",
"@pushrocks/smartpromise": "^3.1.3", "@push.rocks/smartpromise": "^4.0.3",
"@pushrocks/smartrequest": "^1.1.51", "@push.rocks/smartrequest": "^2.0.18",
"@pushrocks/smartspawn": "^2.0.9", "@push.rocks/smartstring": "^4.0.7",
"@pushrocks/smartstring": "^3.0.24", "@tsclass/tsclass": "^4.0.42",
"@pushrocks/smartsystem": "^2.0.9", "@types/ws": "^8.5.5",
"@tsclass/tsclass": "^3.0.29", "ws": "^8.13.0"
"@types/ws": "^7.4.0",
"ws": "^7.4.2"
}, },
"files": [ "files": [
"ts/**/*", "ts/**/*",

4903
pnpm-lock.yaml generated Normal file

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,10 +1,13 @@
import { expect, tap } from '@pushrocks/tapbundle'; import { expect, tap } from '@push.rocks/tapbundle';
import * as smartproxy from '../ts/index'; import * as smartproxy from '../ts/index.js';
let testProxy: smartproxy.SmartProxy; let testProxy: smartproxy.NetworkProxy;
tap.test('first test', async () => { tap.test('first test', async () => {
testProxy = new smartproxy.SmartProxy({}); testProxy = new smartproxy.NetworkProxy({
port: 3001,
});
expect(testProxy).toBeInstanceOf(smartproxy.NetworkProxy);
}); });
tap.test('should start the testproxy', async () => { tap.test('should start the testproxy', async () => {
@ -12,9 +15,9 @@ tap.test('should start the testproxy', async () => {
}); });
tap.test('should supply reverse proxy config', async () => { tap.test('should supply reverse proxy config', async () => {
testProxy.updateReverseConfigs([ testProxy.updateProxyConfigs([
{ {
destinationIp: 'localhost', destinationIp: '127.0.0.1',
destinationPort: '3000', destinationPort: '3000',
hostName: 'push.rocks', hostName: 'push.rocks',
privateKey: `-----BEGIN PRIVATE KEY----- privateKey: `-----BEGIN PRIVATE KEY-----

8
ts/00_commitinfo_data.ts Normal file
View File

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

View File

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

View File

@ -1,13 +1,26 @@
import { expose } from '@pushrocks/smartspawn'; import * as plugins from './smartproxy.plugins.js';
import * as plugins from './smartproxy.plugins'; import { ProxyRouter } from './smartproxy.classes.router.js';
import { SmartproxyRouter } from './smartproxy.classes.router';
export class ProxyWorker { export interface INetworkProxyOptions {
port: number;
}
export class NetworkProxy {
// INSTANCE
public options: INetworkProxyOptions;
public proxyConfigs: plugins.tsclass.network.IReverseProxyConfig[] = []; public proxyConfigs: plugins.tsclass.network.IReverseProxyConfig[] = [];
public httpsServer: plugins.https.Server; // | plugins.http.Server; public httpsServer: plugins.https.Server;
public port = 8001; public router = new ProxyRouter();
public router = new SmartproxyRouter();
public socketMap = new plugins.lik.ObjectMap<plugins.net.Socket>(); public socketMap = new plugins.lik.ObjectMap<plugins.net.Socket>();
public defaultHeaders: { [key: string]: string } = {};
public alreadyAddedReverseConfigs: {
[hostName: string]: plugins.tsclass.network.IReverseProxyConfig;
} = {};
constructor(optionsArg: INetworkProxyOptions) {
this.options = optionsArg;
}
/** /**
* starts the proxyInstance * starts the proxyInstance
@ -103,33 +116,50 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
-----END CERTIFICATE----- -----END CERTIFICATE-----
`, `,
}, },
async (req, res) => { async (originRequest, originResponse) => {
console.log('got request'); /**
const destinationConfig = this.router.routeReq(req); * endRequest function
* can be used to prematurely end a request
// endRequest function */
const endRequest = ( const endOriginReqRes = (
statusArg: number = 404, statusArg: number = 404,
messageArg: string = 'This route is not available on this server.', messageArg: string = 'This route is not available on this server.',
headers: plugins.http.OutgoingHttpHeaders = {} headers: plugins.http.OutgoingHttpHeaders = {}
) => { ) => {
res.writeHead(statusArg, messageArg); originResponse.writeHead(statusArg, messageArg);
res.end(messageArg); originResponse.end(messageArg);
if (originRequest.socket !== originResponse.socket) {
console.log('hey, something is strange.');
}
originResponse.destroy();
}; };
console.log(
`got request: ${originRequest.headers.host}${plugins.url.parse(originRequest.url).path}`
);
const destinationConfig = this.router.routeReq(originRequest);
if (!destinationConfig) {
console.log(
`${originRequest.headers.host} can't be routed properly. Terminating request.`
);
endOriginReqRes();
return;
}
// authentication // authentication
if (destinationConfig.authentication) { if (destinationConfig.authentication) {
const authInfo = destinationConfig.authentication; const authInfo = destinationConfig.authentication;
switch (authInfo.type) { switch (authInfo.type) {
case 'Basic': case 'Basic':
const authHeader = req.headers.authorization; const authHeader = originRequest.headers.authorization;
if (authHeader) { if (authHeader) {
if (!authHeader.includes('Basic ')) { if (!authHeader.includes('Basic ')) {
return endRequest(401, 'Authentication required', { return endOriginReqRes(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 ', ''); const authStringBase64 = originRequest.headers.authorization.replace('Basic ', '');
const authString: string = plugins.smartstring.base64.decode(authStringBase64); const authString: string = plugins.smartstring.base64.decode(authStringBase64);
const userPassArray = authString.split(':'); const userPassArray = authString.split(':');
const user = userPassArray[0]; const user = userPassArray[0];
@ -137,12 +167,12 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
if (user === authInfo.user && pass === authInfo.pass) { if (user === authInfo.user && pass === authInfo.pass) {
console.log('request successfully authenticated'); console.log('request successfully authenticated');
} else { } else {
return endRequest(403, 'Forbidden: Wrong credentials'); return endOriginReqRes(403, 'Forbidden: Wrong credentials');
} }
} }
break; break;
default: default:
return endRequest( return endOriginReqRes(
403, 403,
'Forbidden: unsupported authentication method configured. Please report to the admin.' 'Forbidden: unsupported authentication method configured. Please report to the admin.'
); );
@ -151,98 +181,193 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
let destinationUrl: string; let destinationUrl: string;
if (destinationConfig) { if (destinationConfig) {
destinationUrl = `http://${destinationConfig.destinationIp}:${destinationConfig.destinationPort}${req.url}`; destinationUrl = `http://${destinationConfig.destinationIp}:${destinationConfig.destinationPort}${originRequest.url}`;
} else { } else {
return endRequest(); return endOriginReqRes();
} }
console.log(destinationUrl); console.log(destinationUrl);
const response = await plugins.smartrequest.request( const proxyResponse = await plugins.smartrequest.request(
destinationUrl, destinationUrl,
{ {
method: req.method, method: originRequest.method,
headers: req.headers, headers: {
...originRequest.headers,
'X-Forwarded-Host': originRequest.headers.host,
'X-Forwarded-Proto': 'https',
},
keepAlive: true,
}, },
true, // lets make this streaming true, // lets make this streaming
(request) => { (proxyRequest) => {
req.on('data', (data) => { originRequest.on('data', (data) => {
request.write(data); proxyRequest.write(data);
}); });
req.on('end', (data) => { originRequest.on('end', (data) => {
request.end(); proxyRequest.end();
});
originRequest.on('error', () => {
proxyRequest.end();
});
originRequest.on('close', () => {
proxyRequest.end();
});
originRequest.on('timeout', () => {
proxyRequest.end();
originRequest.destroy();
});
proxyRequest.on('error', () => {
endOriginReqRes();
}); });
} }
); );
res.statusCode = response.statusCode; originResponse.statusCode = proxyResponse.statusCode;
console.log(response.statusCode); console.log(proxyResponse.statusCode);
for (const header of Object.keys(response.headers)) { for (const defaultHeader of Object.keys(this.defaultHeaders)) {
res.setHeader(header, response.headers[header]); originResponse.setHeader(defaultHeader, this.defaultHeaders[defaultHeader]);
} }
response.on('data', (data) => { for (const header of Object.keys(proxyResponse.headers)) {
res.write(data); originResponse.setHeader(header, proxyResponse.headers[header]);
}
proxyResponse.on('data', (data) => {
originResponse.write(data);
}); });
response.on('end', () => { proxyResponse.on('end', () => {
res.end(); originResponse.end();
});
proxyResponse.on('error', () => {
originResponse.destroy();
});
proxyResponse.on('close', () => {
originResponse.end();
});
proxyResponse.on('timeout', () => {
originResponse.end();
originResponse.destroy();
}); });
} }
); );
// Enable websockets // Enable websockets
const wss = new plugins.ws.Server({ server: this.httpsServer }); const wsServer = new plugins.ws.WebSocketServer({ server: this.httpsServer });
wss.on('connection', (ws: plugins.wsDefault) => { wsServer.on(
console.log('got connection for wsc'); 'connection',
const wscConnected = plugins.smartpromise.defer(); async (wsIncoming: plugins.wsDefault, reqArg: plugins.http.IncomingMessage) => {
console.log(
`wss proxy: got connection for wsc for https://${reqArg.headers.host}${reqArg.url}`
);
const wsc = new plugins.wsDefault(this.router.routeWs(ws), { let wsOutgoing: plugins.wsDefault;
headers: {
Host: ws.url,
},
});
wsc.on('open', () => {
wscConnected.resolve();
});
ws.on('message', async (message) => { const outGoingDeferred = plugins.smartpromise.defer();
await wscConnected.promise;
wsc.emit('message', message);
});
wsc.on('message', (message) => {
ws.emit('message', message);
});
// handle closing try {
ws.on('close', (message) => { wsOutgoing = new plugins.wsDefault(
wsc.close(); `ws://${this.router.routeReq(reqArg).destinationIp}:${
}); this.router.routeReq(reqArg).destinationPort
wsc.on('close', (message) => { }${reqArg.url}`
ws.close(); );
}); console.log('wss proxy: initiated outgoing proxy');
}); wsOutgoing.on('open', async () => {
this.httpsServer.keepAliveTimeout = 61000; outGoingDeferred.resolve();
this.httpsServer.headersTimeout = 65000; });
} catch (err) {
console.log(err);
wsIncoming.terminate();
return;
}
this.httpsServer.on('connection', (connection) => { 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.headersTimeout = 600 * 1000;
this.httpsServer.on('connection', (connection: plugins.net.Socket) => {
this.socketMap.add(connection); this.socketMap.add(connection);
console.log(`added connection. now ${this.socketMap.getArray().length} sockets connected.`);
const cleanupConnection = () => {
if (this.socketMap.checkForObject(connection)) {
this.socketMap.remove(connection);
console.log(`removed connection. ${this.socketMap.getArray().length} sockets remaining.`);
connection.destroy();
}
};
connection.on('close', () => { connection.on('close', () => {
this.socketMap.remove(connection); cleanupConnection();
});
connection.on('error', () => {
cleanupConnection();
});
connection.on('end', () => {
cleanupConnection();
});
connection.on('timeout', () => {
cleanupConnection();
}); });
}); });
this.httpsServer.listen(this.port); this.httpsServer.listen(this.options.port);
console.log(`ProxyWorker -> OK: now listening for new connections on port ${this.port}`); console.log(
`NetworkProxy -> OK: now listening for new connections on port ${this.options.port}`
);
} }
public async updateProxyConfigs(proxyConfigsArg: plugins.tsclass.network.IReverseProxyConfig[]) { public async updateProxyConfigs(proxyConfigsArg: plugins.tsclass.network.IReverseProxyConfig[]) {
console.log(`got new proxy configs`);
this.proxyConfigs = proxyConfigsArg; this.proxyConfigs = proxyConfigsArg;
this.router.setNewProxyConfigs(proxyConfigsArg); this.router.setNewProxyConfigs(proxyConfigsArg);
for (const hostCandidate of this.proxyConfigs) { for (const hostCandidate of this.proxyConfigs) {
// console.log(hostCandidate); // console.log(hostCandidate);
const existingHostNameConfig = this.alreadyAddedReverseConfigs[hostCandidate.hostName];
if (!existingHostNameConfig) {
this.alreadyAddedReverseConfigs[hostCandidate.hostName] = hostCandidate;
} else {
if (
existingHostNameConfig.publicKey === hostCandidate.publicKey &&
existingHostNameConfig.privateKey === hostCandidate.privateKey
) {
continue;
} else {
this.alreadyAddedReverseConfigs[hostCandidate.hostName] = hostCandidate;
}
}
this.httpsServer.addContext(hostCandidate.hostName, { this.httpsServer.addContext(hostCandidate.hostName, {
cert: hostCandidate.publicKey, cert: hostCandidate.publicKey,
key: hostCandidate.privateKey, key: hostCandidate.privateKey,
}); });
this.httpsServer;
}
}
public async addDefaultHeaders(headersArg: { [key: string]: string }) {
for (const headerKey of Object.keys(headersArg)) {
this.defaultHeaders[headerKey] = headersArg[headerKey];
} }
/* this.httpsServer.close();
this.httpsServer.listen(this.port); */
} }
public async stop() { public async stop() {
@ -256,22 +381,3 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
await done.promise; await done.promise;
} }
} }
const proxyWorkerInstance = new ProxyWorker();
// the following is interesting for the master process only
const proxyWorkerCalls = {
stop: async () => {
await proxyWorkerInstance.stop();
},
start: async () => {
await proxyWorkerInstance.start();
},
updateReverseConfigs: async (configArray: plugins.tsclass.network.IReverseProxyConfig[]) => {
await proxyWorkerInstance.updateProxyConfigs(configArray);
},
};
export type TProxyWorkerCalls = typeof proxyWorkerCalls;
expose(proxyWorkerCalls);
console.log('ProxyWorker initialized');

View File

@ -1,6 +1,6 @@
import * as plugins from './smartproxy.plugins'; import * as plugins from './smartproxy.plugins.js';
export class SmartproxyRouter { export class ProxyRouter {
public reverseProxyConfigs: plugins.tsclass.network.IReverseProxyConfig[] = []; public reverseProxyConfigs: plugins.tsclass.network.IReverseProxyConfig[] = [];
/** /**
@ -21,12 +21,4 @@ export class SmartproxyRouter {
}); });
return correspodingReverseProxyConfig; return correspodingReverseProxyConfig;
} }
public routeWs(ws: plugins.wsDefault) {
const originalHost = plugins.url.parse(ws.url).host;
const correspodingReverseProxyConfig = this.reverseProxyConfigs.find((reverseConfig) => {
return reverseConfig.hostName === originalHost;
});
return correspodingReverseProxyConfig.destinationIp;
}
} }

View File

@ -1,57 +0,0 @@
import * as plugins from './smartproxy.plugins';
import { TProxyWorkerCalls } from './smartproxy.classes.proxyworker';
import { TPortProxyCalls } from './smartproxy.portproxy';
export interface ISmartProxyOptions {
port?: number;
}
export class SmartProxy {
public smartsystem = new plugins.smartsystem.Smartsystem();
public reverseConfigs: plugins.tsclass.network.IReverseProxyConfig[] = [];
public proxyWorkerFunctions: plugins.smartspawn.ModuleThread<TProxyWorkerCalls>;
public portProxyFunctions: plugins.smartspawn.ModuleThread<TPortProxyCalls>;
public options: ISmartProxyOptions;
constructor(optionsArg: ISmartProxyOptions = {}) {
this.options = optionsArg;
}
public async updateReverseConfigs(
reverseConfigsArg: plugins.tsclass.network.IReverseProxyConfig[]
) {
// TODO search for old hostCandidates with that target
this.reverseConfigs = reverseConfigsArg;
if (this.proxyWorkerFunctions) {
await this.proxyWorkerFunctions.updateReverseConfigs(this.reverseConfigs);
}
}
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')
);
await this.portProxyFunctions.start(this.options.port);
await this.proxyWorkerFunctions.start();
console.log('successfully spawned portproxy and proxyworkers!');
}
public async stop() {
await this.proxyWorkerFunctions.stop();
await plugins.smartspawn.Thread.terminate(this.proxyWorkerFunctions);
console.log('proxy worker stopped');
await this.portProxyFunctions.stop();
await plugins.smartspawn.Thread.terminate(this.portProxyFunctions);
console.log('portproxy stopped');
console.log('Terminated all childs!');
}
}

View File

@ -0,0 +1,32 @@
import * as plugins from './smartproxy.plugins.js';
export class SslRedirect {
httpServer: plugins.http.Server;
port: number;
constructor(portArg: number) {
this.port = portArg;
}
public async start() {
this.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();
});
this.httpServer.listen(this.port);
}
public async stop() {
const done = plugins.smartpromise.defer();
this.httpServer.close(() => {
done.resolve();
});
await done.promise;
}
}

View File

@ -12,14 +12,13 @@ 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 smartpromise from '@pushrocks/smartpromise'; import * as smartdelay from '@push.rocks/smartdelay';
import * as smartrequest from '@pushrocks/smartrequest'; import * as smartpromise from '@push.rocks/smartpromise';
import * as smartspawn from '@pushrocks/smartspawn'; import * as smartrequest from '@push.rocks/smartrequest';
import * as smartstring from '@pushrocks/smartstring'; import * as smartstring from '@push.rocks/smartstring';
import * as smartsystem from '@pushrocks/smartsystem';
export { lik, smartrequest, smartpromise, smartspawn, smartstring, smartsystem }; export { lik, smartdelay, smartrequest, smartpromise, smartstring };
// third party scope // third party scope
import * as ws from 'ws'; import * as ws from 'ws';

View File

@ -1,56 +1,70 @@
import * as plugins from './smartproxy.plugins'; import * as plugins from './smartproxy.plugins.js';
import { expose } from '@pushrocks/smartspawn';
import * as net from 'net'; import * as net from 'net';
let netServer: plugins.net.Server;
let httpServer: plugins.http.Server;
const portProxyCalls = { export class PortProxy {
start: async (portArg = 8000) => { netServer: plugins.net.Server;
httpServer = plugins.http.createServer((request, response) => { fromPort: number;
const requestUrl = new URL(request.url, `http://${request.headers.host}`); toPort: number;
const completeUrlWithoutProtocol = `${requestUrl.host}${requestUrl.pathname}${requestUrl.search}`;
const redirectUrl = `https://${completeUrlWithoutProtocol}`; constructor(fromPortArg: number, toPortArg: number) {
console.log(`Got http request for http://${completeUrlWithoutProtocol}`); this.fromPort = fromPortArg;
console.log(`Redirecting to ${redirectUrl}`); this.toPort = toPortArg;
response.writeHead(302, { }
Location: redirectUrl,
}); public async start() {
response.end(); const cleanUpSockets = (from: plugins.net.Socket, to: plugins.net.Socket) => {
}); from.end();
httpServer.listen(7999); to.end();
netServer = net from.removeAllListeners();
to.removeAllListeners();
from.unpipe();
to.unpipe();
from.destroy();
to.destroy();
};
this.netServer = net
.createServer((from) => { .createServer((from) => {
const to = net.createConnection({ const to = net.createConnection({
host: 'localhost', host: 'localhost',
port: 8001, port: this.toPort,
}); });
from.setTimeout(120000);
from.pipe(to); from.pipe(to);
to.pipe(from); to.pipe(from);
from.on('error', () => { from.on('error', () => {
from.end(), to.end(); cleanUpSockets(from, to);
}); });
to.on('error', () => { to.on('error', () => {
from.end(), to.end(); cleanUpSockets(from, to);
}); });
from.on('close', () => { from.on('close', () => {
to.end(); cleanUpSockets(from, to);
});
to.on('close', () => {
cleanUpSockets(from, to);
});
from.on('timeout', () => {
cleanUpSockets(from, to);
});
to.on('timeout', () => {
cleanUpSockets(from, to);
});
from.on('end', () => {
cleanUpSockets(from, to);
});
to.on('end', () => {
cleanUpSockets(from, to);
}); });
}) })
.listen(portArg); .listen(this.fromPort);
console.log(`PortProxy -> OK: Now listening on port ${portArg}`); console.log(`PortProxy -> OK: Now listening on port ${this.fromPort}`);
}, }
stop: async () => {
public async stop() {
const done = plugins.smartpromise.defer(); const done = plugins.smartpromise.defer();
httpServer.close(() => { this.netServer.close(() => {
netServer.close(() => { done.resolve();
done.resolve();
});
}); });
await done.promise; await done.promise;
}, }
}; }
export type TPortProxyCalls = typeof portProxyCalls;
expose(portProxyCalls);
console.log('PortProxy Initialized');

11
tsconfig.json Normal file
View File

@ -0,0 +1,11 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "nodenext",
"esModuleInterop": true,
"verbatimModuleSyntax": true,
}
}

View File

@ -1,17 +0,0 @@
{
"extends": ["tslint:latest", "tslint-config-prettier"],
"rules": {
"semicolon": [true, "always"],
"no-console": false,
"ordered-imports": false,
"object-literal-sort-keys": false,
"member-ordering": {
"options":{
"order": [
"static-method"
]
}
}
},
"defaultSeverity": "warning"
}