Skip to content

Commit f4e480b

Browse files
abhinavsinghdependabot[bot]pre-commit-ci[bot]
authored
[v2.4.3] Support for dynamic reverse proxy routes (#1188)
* Merge pull request #1162 from abhinavsingh/master v2.4.2 (#1158) * pip prod(deps): bump blacksheep from 1.2.2 to 1.2.7 (#1161) Bumps [blacksheep](https://github.com/Neoteroi/BlackSheep) from 1.2.2 to 1.2.7. - [Release notes](https://github.com/Neoteroi/BlackSheep/releases) - [Changelog](https://github.com/Neoteroi/BlackSheep/blob/main/CHANGELOG.md) - [Commits](Neoteroi/BlackSheep@v1.2.2...v1.2.7) --- updated-dependencies: - dependency-name: blacksheep dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump fregante/setup-git-user from 1.0.1 to 1.1.0 (#1160) Bumps [fregante/setup-git-user](https://github.com/fregante/setup-git-user) from 1.0.1 to 1.1.0. - [Release notes](https://github.com/fregante/setup-git-user/releases) - [Commits](fregante/setup-git-user@v1.0.1...v1.1.0) --- updated-dependencies: - dependency-name: fregante/setup-git-user dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * npm: bump ts-node from 10.7.0 to 10.8.0 in /dashboard (#1159) Bumps [ts-node](https://github.com/TypeStrong/ts-node) from 10.7.0 to 10.8.0. - [Release notes](https://github.com/TypeStrong/ts-node/releases) - [Commits](TypeStrong/ts-node@v10.7.0...v10.8.0) --- updated-dependencies: - dependency-name: ts-node dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * npm: bump ws from 8.5.0 to 8.6.0 in /dashboard (#1165) Bumps [ws](https://github.com/websockets/ws) from 8.5.0 to 8.6.0. - [Release notes](https://github.com/websockets/ws/releases) - [Commits](websockets/ws@8.5.0...8.6.0) --- updated-dependencies: - dependency-name: ws dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Abhinav Singh <[email protected]> * Delete FUNDING.yml * pip prod(deps): bump pytest from 6.2.5 to 7.0.1 (#1164) Bumps [pytest](https://github.com/pytest-dev/pytest) from 6.2.5 to 7.0.1. - [Release notes](https://github.com/pytest-dev/pytest/releases) - [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst) - [Commits](pytest-dev/pytest@6.2.5...7.0.1) --- updated-dependencies: - dependency-name: pytest dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Abhinav Singh <[email protected]> * pip prod(deps): bump rope from 0.22.0 to 1.1.1 (#1167) Bumps [rope](https://github.com/python-rope/rope) from 0.22.0 to 1.1.1. - [Release notes](https://github.com/python-rope/rope/releases) - [Changelog](https://github.com/python-rope/rope/blob/master/CHANGELOG.md) - [Commits](python-rope/rope@0.22.0...1.1.1) --- updated-dependencies: - dependency-name: rope dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * pip prod(deps): bump starlette from 0.17.1 to 0.19.1 (#1168) Bumps [starlette](https://github.com/encode/starlette) from 0.17.1 to 0.19.1. - [Release notes](https://github.com/encode/starlette/releases) - [Changelog](https://github.com/encode/starlette/blob/master/docs/release-notes.md) - [Commits](encode/starlette@0.17.1...0.19.1) --- updated-dependencies: - dependency-name: starlette dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * pip prod(deps): bump mypy from 0.940 to 0.960 (#1170) Bumps [mypy](https://github.com/python/mypy) from 0.940 to 0.960. - [Release notes](https://github.com/python/mypy/releases) - [Commits](python/mypy@v0.940...v0.960) --- updated-dependencies: - dependency-name: mypy dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Create FUNDING.yml * Address yaml lint * Bump actions/cache from 3.0.2 to 3.0.4 (#1185) Bumps [actions/cache](https://github.com/actions/cache) from 3.0.2 to 3.0.4. - [Release notes](https://github.com/actions/cache/releases) - [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md) - [Commits](actions/cache@v3.0.2...v3.0.4) --- updated-dependencies: - dependency-name: actions/cache dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump actions/setup-python from 3 to 4 (#1186) Bumps [actions/setup-python](https://github.com/actions/setup-python) from 3 to 4. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](actions/setup-python@v3...v4) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * pip prod(deps): bump py-spy from 0.3.11 to 0.3.12 (#1174) Bumps [py-spy](https://github.com/benfred/py-spy) from 0.3.11 to 0.3.12. - [Release notes](https://github.com/benfred/py-spy/releases) - [Changelog](https://github.com/benfred/py-spy/blob/master/CHANGELOG.md) - [Commits](benfred/py-spy@v0.3.11...v0.3.12) --- updated-dependencies: - dependency-name: py-spy dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * pip prod(deps): bump mypy from 0.960 to 0.961 (#1187) Bumps [mypy](https://github.com/python/mypy) from 0.960 to 0.961. - [Release notes](https://github.com/python/mypy/releases) - [Commits](python/mypy@v0.960...v0.961) --- updated-dependencies: - dependency-name: mypy dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Add support for dynamic reverse proxy routing (#1180) * Add support for dynamic reverse proxy routing. Plugins must implement the `handle_route(self, request, pattern) -> Url` method from the base class to provide a choice of upstream url to serve. This work is backward compatible a.k.a. Old style static route patterns with hardcoded upstream urls will continue to work as-is. See `ReverseProxyBasePlugin` documentation for more details. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Address type issues * Fix spellcheck * Attempt to solve type errors * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Py3.8 also doesnt allow subscriptable pattern type * Remove debug print Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 8a00695 commit f4e480b

File tree

13 files changed

+217
-118
lines changed

13 files changed

+217
-118
lines changed

.github/FUNDING.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
---
2-
open_collective: proxypy
3-
...
2+
# These are supported funding model platforms
3+
4+
github: abhinavsingh

.github/workflows/test-library.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jobs:
7272
container-platforms: ${{ steps.container.outputs.platforms }}
7373
steps:
7474
- name: Switch to using Python 3.9 by default
75-
uses: actions/setup-python@v3
75+
uses: actions/setup-python@v4
7676
with:
7777
python-version: 3.9
7878
- name: >-
@@ -135,7 +135,7 @@ jobs:
135135
- name: Set up pip cache
136136
if: >-
137137
steps.request-check.outputs.release-requested != 'true'
138-
uses: actions/[email protected].2
138+
uses: actions/[email protected].4
139139
with:
140140
path: ${{ steps.pip-cache-dir.outputs.dir }}
141141
key: >-
@@ -225,7 +225,7 @@ jobs:
225225

226226
steps:
227227
- name: Switch to using Python v3.10
228-
uses: actions/setup-python@v3
228+
uses: actions/setup-python@v4
229229
with:
230230
python-version: '3.10'
231231
- name: >-
@@ -244,7 +244,7 @@ jobs:
244244
run: >-
245245
echo "::set-output name=dir::$(pip cache dir)"
246246
- name: Set up pip cache
247-
uses: actions/[email protected].2
247+
uses: actions/[email protected].4
248248
with:
249249
path: ${{ steps.pip-cache.outputs.dir }}
250250
key: >-
@@ -284,7 +284,7 @@ jobs:
284284
if: >-
285285
fromJSON(needs.pre-setup.outputs.is-untagged-devel)
286286
|| fromJSON(needs.pre-setup.outputs.release-requested)
287-
uses: fregante/setup-git-user@v1.0.1
287+
uses: fregante/setup-git-user@v1.1.0
288288
- name: >-
289289
Tag the release in the local Git repo
290290
as ${{ needs.pre-setup.outputs.git-tag }}
@@ -350,7 +350,7 @@ jobs:
350350

351351
steps:
352352
- name: Switch to using Python v3.10
353-
uses: actions/setup-python@v3
353+
uses: actions/setup-python@v4
354354
with:
355355
python-version: '3.10'
356356
- name: >-
@@ -369,7 +369,7 @@ jobs:
369369
run: >-
370370
echo "::set-output name=dir::$(pip cache dir)"
371371
- name: Set up pip cache
372-
uses: actions/[email protected].2
372+
uses: actions/[email protected].4
373373
with:
374374
path: ${{ steps.pip-cache.outputs.dir }}
375375
key: >-
@@ -467,7 +467,7 @@ jobs:
467467

468468
steps:
469469
- name: Switch to using Python v${{ matrix.python }}
470-
uses: actions/setup-python@v3
470+
uses: actions/setup-python@v4
471471
with:
472472
python-version: ${{ matrix.python }}
473473
- name: >-
@@ -486,7 +486,7 @@ jobs:
486486
run: >-
487487
echo "::set-output name=dir::$(pip cache dir)"
488488
- name: Set up pip cache
489-
uses: actions/[email protected].2
489+
uses: actions/[email protected].4
490490
with:
491491
path: ${{ steps.pip-cache.outputs.dir }}
492492
key: >-
@@ -670,7 +670,7 @@ jobs:
670670
steps:
671671
- uses: actions/checkout@v3
672672
- name: Setup Python
673-
uses: actions/setup-python@v3
673+
uses: actions/setup-python@v4
674674
with:
675675
python-version: ${{ matrix.python }}
676676
- name: Brew
@@ -724,7 +724,7 @@ jobs:
724724
with:
725725
fetch-depth: 0
726726
- name: Setup Python
727-
uses: actions/setup-python@v3
727+
uses: actions/setup-python@v4
728728
with:
729729
python-version: ${{ matrix.python }}
730730
- name: Install Pip Dependencies
@@ -1057,7 +1057,7 @@ jobs:
10571057
fetch-depth: 1
10581058
ref: ${{ github.event.inputs.release-commitish }}
10591059
- name: Setup git user as [bot]
1060-
uses: fregante/setup-git-user@v1.0.1
1060+
uses: fregante/setup-git-user@v1.1.0
10611061

10621062
- name: >-
10631063
Tag the release in the local Git repo

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2315,9 +2315,9 @@ usage: -m [-h] [--tunnel-hostname TUNNEL_HOSTNAME] [--tunnel-port TUNNEL_PORT]
23152315
[--filtered-client-ips FILTERED_CLIENT_IPS]
23162316
[--filtered-url-regex-config FILTERED_URL_REGEX_CONFIG]
23172317

2318-
proxy.py v2.4.2.dev11+g0beb02d.d20220420
2318+
proxy.py v2.4.3.dev14+gc6b2de6.d20220605
23192319

2320-
options:
2320+
optional arguments:
23212321
-h, --help show this help message and exit
23222322
--tunnel-hostname TUNNEL_HOSTNAME
23232323
Default: None. Remote hostname or IP address to which
@@ -2334,11 +2334,11 @@ options:
23342334
--tunnel-remote-port TUNNEL_REMOTE_PORT
23352335
Default: 8899. Remote port which will be forwarded
23362336
locally for proxy.
2337-
--threadless Default: True. Enabled by default on Python 3.8+ (mac,
2338-
linux). When disabled a new thread is spawned to
2337+
--threadless Default: False. Enabled by default on Python 3.8+
2338+
(mac, linux). When disabled a new thread is spawned to
23392339
handle each client connection.
2340-
--threaded Default: False. Disabled by default on Python < 3.8
2341-
and windows. When enabled a new thread is spawned to
2340+
--threaded Default: True. Disabled by default on Python < 3.8 and
2341+
windows. When enabled a new thread is spawned to
23422342
handle each client connection.
23432343
--num-workers NUM_WORKERS
23442344
Defaults to number of CPU cores.
@@ -2434,8 +2434,8 @@ options:
24342434
Default: None. Signing certificate to use for signing
24352435
dynamically generated HTTPS certificates. If used,
24362436
must also pass --ca-key-file and --ca-signing-key-file
2437-
--ca-file CA_FILE Default: /Users/abhinavsingh/Dev/proxy.py/venv310/lib/
2438-
python3.10/site-packages/certifi/cacert.pem. Provide
2437+
--ca-file CA_FILE Default: /Users/abhinavsingh/Dev/proxy.py/venv373/lib/
2438+
python3.7/site-packages/certifi/cacert.pem. Provide
24392439
path to custom CA bundle for peer certificate
24402440
verification
24412441
--ca-signing-key-file CA_SIGNING_KEY_FILE

benchmark/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
aiohttp==3.8.1
2-
blacksheep==1.2.2
3-
starlette==0.17.1
2+
blacksheep==1.2.7
3+
starlette==0.19.1
44
tornado==6.1
55
uvicorn==0.16.0

dashboard/package-lock.json

Lines changed: 72 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dashboard/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@
4848
"rollup-plugin-copy": "^3.4.0",
4949
"rollup-plugin-javascript-obfuscator": "^1.0.4",
5050
"rollup-plugin-typescript": "^1.0.1",
51-
"ts-node": "^10.7.0",
51+
"ts-node": "^10.8.0",
5252
"typescript": "^4.5.4",
53-
"ws": "^8.5.0"
53+
"ws": "^8.6.0"
5454
}
5555
}

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@
320320
(_py_class_role, 'T'),
321321
(_py_class_role, 'HostPort'),
322322
(_py_class_role, 'TcpOrTlsSocket'),
323+
(_py_class_role, 're.Pattern'),
323324
(_py_obj_role, 'proxy.core.work.threadless.T'),
324325
(_py_obj_role, 'proxy.core.work.work.T'),
325326
(_py_obj_role, 'proxy.core.base.tcp_server.T'),

proxy/common/types.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
:copyright: (c) 2013-present by Abhinav Singh and contributors.
99
:license: BSD, see LICENSE for more details.
1010
"""
11+
import re
1112
import ssl
13+
import sys
1214
import queue
1315
import socket
1416
import ipaddress
@@ -30,3 +32,10 @@
3032
IpAddress = Union[ipaddress.IPv4Address, ipaddress.IPv6Address]
3133
TcpOrTlsSocket = Union[ssl.SSLSocket, socket.socket]
3234
HostPort = Tuple[str, int]
35+
36+
if sys.version_info.minor == 6:
37+
RePattern = Any
38+
elif sys.version_info.minor in (7, 8):
39+
RePattern = re.Pattern # type: ignore
40+
else:
41+
RePattern = re.Pattern[Any] # type: ignore

0 commit comments

Comments
 (0)