Commit Graph

940 Commits

Author SHA1 Message Date
Abhinav Singh ad2e1074b3
Leakage class (#1510)
* Leakage class

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix lint issues

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-11-22 10:07:27 +05:30
Abhinav Singh 71d796baa9
Dont crash threadless if work shutdown errors out (#1509) 2024-11-22 09:28:32 +05:30
Abhinav Singh 5076c3040c Lint fix 2024-11-14 19:39:50 +05:30
Abhinav Singh edad693fbb Cast `--inactive-conn-cleanup-timeout` to float 2024-11-14 19:09:42 +05:30
Abhinav Singh 8d81b1426f
`--inactive-conn-cleanup-timeout` (#1504)
* `--inactive-conn-cleanup-timeout`

* Specify default in docs

* Update README

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Clarify usecase is comments

* Lint

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-11-14 18:31:45 +05:30
Abhinav Singh 050ac1c39a
`--rewrite-host-header` flag for reverse proxy (#1492)
* Rewrite Host header during reverse proxy

* bring back `VERIFIED6`

* Lint fixes

* `--rewrite-host-header` flag

* Pass `--rewrite-host-header` for integration tests

* expect `httpbingo.org` as header now due to host rewrite

* Also pass flag during build & test suite
2024-10-15 10:04:31 +05:30
Abhinav Singh 9077c16b1b
`grout` host header & dynamic routing doc (#1490)
* `grout` host header & dynamic routing doc

* spell fix

* Link to repo
2024-10-13 21:04:58 +05:30
Abhinav Singh 79546ff0cd `GroutClientBasePlugin` return None for route to drop the request 2024-10-13 19:46:33 +05:30
Abhinav Singh 16ab675b54
`GroutClientBasePlugin` ability to modify request object (#1489) 2024-10-13 18:32:45 +05:30
Abhinav Singh 0641864478
`GroutClientBasePlugin` and example `GroutClientPlugin` (#1488)
* `GroutClientBasePlugin`

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Silence `S113` false positive

* Remove example url

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-10-13 15:56:16 +05:30
Abhinav Singh c703edac0b Add `grout` wildcard domains and routing doc 2024-10-05 06:47:48 +05:30
dependabot[bot] 48842552a1
Bump actions/download-artifact from 3 to 4 in /.github/workflows in the github_actions group across 1 directory (#1477)
* Bump actions/download-artifact

Bumps the github_actions group with 1 update in the /.github/workflows directory: [actions/download-artifact](https://github.com/actions/download-artifact).


Updates `actions/download-artifact` from 3 to 4
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-type: direct:production
  dependency-group: github_actions
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update test-library.yml

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Abhinav Singh <126065+abhinavsingh@users.noreply.github.com>
2024-09-21 12:46:50 +05:30
Abhinav Singh ebf3599abb
Bump pip group for benchmark comparisions to fix security scanner reports (#1479) 2024-09-21 12:33:42 +05:30
Abhinav Singh c07436c084
Bump workflows to use Ubuntu 24.04 (#1478)
* Bump workflows to use Ubuntu 24.04

* Continue using 20.04 for python 3.6

* Continue using 20.04 for python 3.6 and 3.7

* Indentation fix
2024-09-21 12:11:24 +05:30
Abhinav Singh f5f18e4aea
TLS Intercept conditionally (#1476)
* TLS intercept conditionally

* Lint fixes

* Fix test assertions

* Fix tests

* Bump `sphinxcontrib-spelling == 8.0.0` due to deprecated pypi XML APIs, ref https://github.com/pypi/warehouse/issues/16642

* Disable spellcheck-docs for now until we have a clear path forward
2024-09-21 10:54:07 +05:30
Abhinav Singh a51ddaae41
Add clarity on how `HttpParser` class works (#1466)
* Add clarity on how `HttpParser` class works

* `"python.analysis.autoImportCompletions": true`
2024-08-27 21:33:53 +05:30
Abhinav Singh 05ac288620
Add support for `Upgrade: Derp` custom protocol (#1463)
Add support for `Upgrade: Derp` custom protocol used by @coder
2024-08-23 18:44:03 +05:30
Abhinav Singh 447b68e924 Add `pip` and `Selenium Base` to projects using `proxy.py` 2024-08-16 09:05:34 +05:30
Abhinav Singh aa596f9d0c
Option to not verify upstream ssl (#1459) 2024-08-13 10:45:11 +05:30
Abhinav Singh 0bfd7d7fdb
Fix client for HTTPS endpoints with Python 3.12 (#1454)
* Fix client for HTTPS endpoints for python 3.12

* Use only `DEFAULT_SSL_CONTEXT_OPTIONS` to prevent `CRIME` attacks

* lint fix

* install certifi types

* pre commit

* Avoid using dep options for >=3.10

* More tests

* Fix lint issues

* Use `3.12` by default everywhere

* Skip `grout -h` test on windows

* Add http only test

* Rollback to python versions, 3.12 causes doc/lint failures

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Keep proxy.py benchmarking on so that users dont run into surprises

* Install certifi

* No need of certifi

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-08-12 18:08:52 +05:30
Abhinav Singh 74c42f6e57
`setup.cfg/extras_require` configuration (#1452)
* Remove usage of requirements file in favor of `setup.cfg/extras_require` configuration

* Fallback to setuptools-scm>=6 because >=7.0.5 dont support python 3.6, see https://github.com/abhinavsingh/proxy.py/pull/1345/files

* Remove unicode symbols from setup.cfg which causes parsing issues on python3.6, ref https://github.com/abhinavsingh/proxy.py/actions/runs/10346098737/job/28634186621\?pr\=1452
2024-08-12 11:57:57 +05:30
Abhinav Singh 6602be3da8 `Prometheus Metrics` documentation 2024-08-11 20:47:23 +05:30
Abhinav Singh 091ba361ef
Prometheus Metrics (#1447)
* Add metrics server endpoint

* Setup metrics subscriber

* `MetricsSubscriber` as context manager

* Fix lint issues

* `--enable-metrics` flag which setup Metrics subscriber, collector and web endpoint

* Use file storage based mechanism to share internal metrics with prometheus exporter endpoint

* Lint fixes

* Move `_setup_metrics_directory` within subscriber which only run once

* Use global `metrics_lock` via flags

* Remove top-level imports for prometheus_client

* Add `requirements-metrics.txt`

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix typo in makefile

* Fix typo

* fix type, lint, flake issues

* Remove event queue prop

* Fix typo

* Give any role to `proxy.http.server.metrics.get_collector`

* rtype

* `emit_request_complete` for web servers

* Fix doc issues

* Refactor

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Rename metrics to start with proxypy_work_

* Startup `MetricsEventSubscriber` as part of proxy

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-08-11 19:30:18 +05:30
Abhinav Singh 71f3c658e8 Use `python:3.12-alpine` in Docker image 2024-08-10 15:57:02 +05:30
Abhinav Singh 579838eea4 Trigger build 2024-08-10 15:45:18 +05:30
Abhinav Singh 50046d3f68
TLS intercept self-signed servers using `--insecure-tls-interception` (#1446)
* Disable mandatory TLS verification with --insecure

* Fix lint issues

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix type issues with `cert_der_to_dict`

* Flake8 exception

* Fix `cert_der_to_dict` where file may not be writter before it is gets used by `_test_decode_cert`

* Silence lint issue due to pylint bug

* Rename flag to `--insecure-tls-interception`

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Reuse `DEFAULT_SSL_CONTEXT_OPTIONS`

* # noqa: WPS436

---------

Co-authored-by: d4x <d_4xfe@proton.me>
Co-authored-by: d4xfe <168460626+d4xfe@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-08-10 12:12:55 +05:30
Abhinav Singh 39854e1d79
Use Python 3.12 as default Docker base image (#1445)
* Use Python 3.12 as default Docker base image

* Add standard OCI labels
2024-08-10 10:28:53 +05:30
Abhinav Singh 1e4e87d515
Support for Python 3.12 (#1444)
* Support for Python 3.12

* Use `assert_called_once_with` and not `called_once_with`

* lint fix

* Fix `test_pac_file_served_from_disk`

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-08-10 09:33:49 +05:30
Abhinav Singh 201d02ce72
Deprecate usage of `ssl.wrap_socket` in favour of `SSLContext.wrap_socket` (#1443)
* Remove use of ssl.wrap_socket

ssl.wrap_socket() has been deprecated since Python 3.7, and isn't
recommended for use, and further, has been removed in Python 3.12.
ssl.SSLContext().wrap_socket() is the new path forward, so switch the
one callsite and the two test cases to use it instead.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix `SSLContext.wrap_socket` params and reusable `DEFAULT_SSL_CONTEXT_OPTIONS`

* Fix test cases

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix e2e tests???

---------

Co-authored-by: Steve Kowalik <steven@wedontsleep.org>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-08-09 23:45:17 +05:30
Abhinav Singh 6ac5aedd26
`Grout Wildcard` documentation (#1441)
* Add documentation around `Grout Wildcard` support

* Fix spellcheck

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-08-06 11:58:58 +05:30
Abhinav Singh b9fa0d5a4c
Renable Codecov (#1440)
* Renable Codecov

* Bump codecov-action and provide CODECOV_TOKEN
2024-08-06 10:02:32 +05:30
Abhinav Singh 2dbc8af0bb
Support Grout Wildcards (#1439)
* Support Grout Wildcards

* Disable `Upload coverage to Codecov` which is already broken for sometime
2024-08-05 23:01:54 +05:30
Abhinav Singh 84c36b60c2
Static route reverse proxy always `needs_upstream` (#1434)
* Static route reverse proxy always needs_upstream

* reverse hack done in https://github.com/abhinavsingh/proxy.py/pull/1371/files\#diff-8e4998393b40035040fb8494b321b9538b897ed0f25d35aeeb037a99f623abc3 to make tests work

* httpbingo is an issue on github workflows
2024-07-28 10:43:37 +05:30
Abhinav Singh a7077cf8db
Add `ModifyRequestHeaderPlugin` (#1420)
* Add `ModifyRequestHeaderPlugin`

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add to README

* Fix lint issues shown by `Python3.11.8`

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-06-09 22:52:37 +05:30
Abhinav Singh e34da54323 Grout (ngrok alternative) using Docker doc 2024-05-16 08:12:47 +05:30
Abhinav Singh afa89bc749 Grout (ngrok alternative) using Docker doc 2024-05-16 01:27:02 +05:30
Abhinav Singh 7bb04c020a
Include `openssl`, `cryptography` and `paramiko` in default DockerHub image (#1409)
* Include `openssl` in docker images to let users try TLS interception using dockerhub images

* Include `requirements-tunnel.txt` within docker image to let users try tunneling using docker images

* Docker is always using py311+, hardcode for now

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Simply `apk add py-cryptography`

* --prefer-binary

* Build deps for cryptography

* make required by pynacl

* Prepare to use base image once it has been published

* Prepare image from `ghcr.io/abhinavsingh/proxy.py:base`

* --no-cache-dir to avoid pip cache bloating

* Optimize base image size

* Use find

* `-y`

* Cut final image `FROM python:3.11-alpine`

* Remove global setuptools and local pip too

* wheel it too

* end and flush

* Try `42.0.4` in next base

* Full path cleanup

* SSL in final copy

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-05-16 00:34:26 +05:30
Abhinav Singh d124d4ec6e Use `base` name for base docker image 2024-05-15 20:28:58 +05:30
Abhinav Singh f19db0ce1b Optimize base docker image size 2024-05-15 20:24:41 +05:30
Abhinav Singh 0380e8301d `--no-cache-dir` to avoid bloating the docker image 2024-05-15 17:16:38 +05:30
Abhinav Singh 58f8847001 `base` workflow 2024-05-15 16:38:05 +05:30
Abhinav Singh 32a6bdd47f
DockerfileBase (#1410) 2024-05-15 16:36:49 +05:30
Abhinav Singh 367205826d
Grout: ngrok Alternative (#1407)
* Grout: An Ngrok Alternative

* Consume `grout` entry point within `proxy.py`

* Revert `check.py`
2024-05-10 13:53:52 +05:30
Abhinav Singh e713752e49
Teardown on unhandled exceptions by work (#1406) 2024-05-09 10:32:47 +05:30
Abhinav Singh fce40f03a3
`compress` option for `serve_static_file` utility method (#1405)
* `compress` option for `serve_static_file` utility method

* Pin to `macos-12` for now

* Change default to `True` (old default behavior)
2024-04-30 17:40:35 +05:30
Abhinav Singh 8b929f079e
Fix ssh tunnel use case (#1400)
* Fix for `--enable-ssh-tunnel` use case

* Update readme with correct instructions

* Update readme
2024-04-26 12:00:35 +05:30
Abhinav Singh 5b0c484e6a
Fix support for multiple ephemeral ports (#1399) 2024-04-25 09:51:52 +05:30
Abhinav Singh 81aa82b9a4
SSH handler/listener plugins (#1398)
* SSH handler/listener plugins

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Readme updated

* Fix listener tests

* pyclassrole

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Trigger rebuild

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Trigger build

* pre-commit default language version 3.10

* Language version

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-04-24 15:13:14 +05:30
Abhinav Singh 67706ac1ef
Reverse proxy ability to return Url, memoryview or TcpServerConnection object (#1397)
* Reverse proxy enhancements

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-04-23 19:21:45 +05:30
Abhinav Singh 380e0cc3ce
Catch `KeyError` within Threadless executors (#1396) 2024-04-23 18:51:53 +05:30