Commit Graph

26 Commits

Author SHA1 Message Date
Abhinav Singh c884338f42
Core acceptor pool doc, cleanup and standalone example (#393)
* Better document acceptor module and add a TCP Echo Server example

* autopep8 formating

* Rename ThreadlessWork --> Work class

* Make initialize, is_inactive and shutdown as optional interface methods.

Also introduce Readables & Writables custom types.

* Move websocket code into its own module

* Add websocket client example

* Cleanup websocket client
2020-07-07 18:01:49 +05:30
Abhinav Singh 4117c5f0d5
Add FilterByClientIpPlugin example (#381) 2020-06-21 21:57:03 +05:30
Abhinav Singh e7aa8a28f7
TLS Interception Cert Generation (#362)
* Use common.pki for interception certificate generation

* Fix tests

* Dont use certificate fields that we dont need, it leads to certificate generation error on Ubuntu

* Prepare for v2.2.0

* npm audit fix
2020-06-09 12:07:00 +05:30
Abhinav Singh 434e2502ec
Add urlparse fix for Python 3.6.x . Deprecate support for Python 3.5.x (#278)
* Add fix required to run on Python 3.6.  Python 3.5.x is no longer supported as it reports syntax error and no longer recognize typing syntax

* Prepare for v2.1.2
2020-01-30 22:35:41 -08:00
Abhinav Singh 87a54a0781
Fixes #267 (#277)
* Fixes #267

* Prepare for v2.1.1
2020-01-30 21:54:02 -08:00
Abhinav Singh ee4e4ce41e
Add py.typed marker, add version checker, remove deprecated methods (#255)
* Add py.typed marker

* Add version-check.py

* Remove deprecated assertDictContainsSubset usage
2020-01-06 21:23:38 -08:00
Abhinav Singh 4713ad6ea7
Homebrew formula (#209)
* Add homebrew formula

* Build PyPi package and Homebrew installation verification

* Check develop

* bdist_wheel reported as error: invalid command "bdist_wheel"

* Move under stable/develop folders to keep Proxy class name same

* uff

* develop installs proxy not proxy.py binary

* Prepend site-packages

* Install typing-extensions explicitly with brew

* Use find_packages

* Most likely failing due to lack of find_packages in current develop branch

* Fix windows setup.py build

* test_static_web_server_serves seems flaky on Ubuntu python 3.8

* Add instructions to install using homebrew

* Disable test_static_web_server_serves on GitHub actions, seems flaky
2019-12-01 19:01:28 -08:00
Abhinav Singh bfbbc5a82a
Test Dashboard backend (#206)
* Update shortlink gif name

* Conditionally run workflows as necessary

* Use pytest

* It works but github workflow is not reporting any status :(

* Separate out badges

* Add python_requires to setup.py
2019-11-30 22:54:20 -08:00
Abhinav Singh 0c4e1cbda9
Testing support improvements (#185)
* Introduce proxy.Proxy context manager.

This is similar to already existing context manager `start` but
`proxy.Proxy` is a class with __enter__ and __exit__ methods. This
allows usage of `proxy.Proxy` both as context manager and for manually
setup and teardown of `proxy.py` during test setUpClass and
teardownClass methods.

* Gracefully shutdown threadless processes

* Update tests and add a VCR method. See #184

* Refactor routes

* Add Proxy to __all__

* Move TestCase under proxy.testing and test_embed.py under tests.embed module to avoid conflict with http module due to a http directory under proxy folder

* Add a base cache plugin class which can be customized for custom cache behaviors

* See #184. Add VCRPlugin which can be enabled within tests using a context manager, e.g. with self.vcr(): ...

* Make cache plugin pluggable + make cache storage pluggable

* Make dashboard npm module agnostic of top level directory

* Symlink dashboard public folder

* Dump devtools within dashboard public folder

* Remove unused 3rd party js
2019-11-21 21:16:01 -08:00
Abhinav Singh bb7006b67a
Move benchmark module within proxy (#181)
* Move benchmark within proxy module

* chmod 0644 for benchmark.py which was executable till now

* Turn utilities into its own section
2019-11-15 23:49:51 -08:00
Abhinav Singh 131e9366ac
Move plugin_examples/ as proxy.plugin and update readme (#179)
* Update dev guide

* Move plugin_examples/ as proxy.plugin

* Update proxy.plugin ref path in readme

* Remove unnecessary port flag

* Remove plugin_examples from github workflows

* dashboard folder is a npm package not python package anymore

* Plugins can now be tried using Docker image
2019-11-15 14:47:50 -08:00
Abhinav Singh c943dd7e27
Allow to pass flags as kwargs too in embed mode (#172)
* Dynamically load devtools instead of on page load

* Add support for passing flags as kwargs to main / start methods.

* Fix tests for refactored code

* Allow proxy.main, proxy.start, proxy.TestCase.

Also update README.md to reflect the same.

* Use Any for **opts

* Move main as __init__ to avoid name conflicts

* Fix tests

* Update setup.py entry_point

* Explicitly install requirements before setup.py

* Explicitly mention packages of interest

* ipv6 fails on ubuntu, use ipv4

* Make typing-extensions optional

* Instead of putting it all under __init__.py, move main.py to proxy.py

* Simply make setup.py module free

* autopep8
2019-11-13 16:38:59 -08:00
Abhinav Singh 93d8a55c0e
Add non-blocking embedded mode feature (#159)
* Fixes #158

* mypy fixes

* Instructions for non-blocking embed mode

* Toggle running flag before shutdown
2019-11-07 20:53:08 -08:00
Abhinav Singh 183d03b866
Separate packages for Dashboard (#157)
* Refactor Makefile and add dashboard setup.py

* Package dashboard as proxy.py-dashboard pip package

* Give dashboard releases its own version

* Fix lib-package reference
2019-11-06 01:33:12 -08:00
Abhinav Singh e14548252c
Proxy.py Dashboard (#141)
* Remove redundant variables

* Initialize frontend dashboard app (written in typescript)

* Add a WebsocketFrame.text method to quickly build a text frame raw packet, also close connection for static file serving, atleast Google Chrome seems to hang up instead of closing the connection

* Add read_and_build_static_file_response method for reusability in plugins

* teardown websocket connection when opcode CONNECTION_CLOSE is received

* First draft of proxy.py dashboard

* Remove uglify, obfuscator is superb enough

* Correct generic V

* First draft of dashboard

* ProtocolConfig is now Flags

* First big refactor toward no-single-file-module

* Working tests

* Update dashboard for refactored imports

* Remove proxy.py as now we can just call python -m proxy -h

* Fix setup.py for refactored code

* Banner update

* Lint check

* Fix dashboard static serving and no UNDER_TEST constant necessary

* Add support for plugin imports when specified in path/to/module.MyPlugin

* Update README with instructions to run proxy.py after refactor

* Move dashboard under /dashboard path

* Rename to devtools.ts

* remove unused

* Update github workflow for new directory structure

* Update test command too

* Fix coverage generation

* *.py is an invalid syntax on windows

* No * on windows

* Enable execution via github zip downloads

* Github Zip downloads cannot be executed as Github puts project under a folder named after Github project, this breaks python interpreter expectation of finding a __main__.py in the root directory

* Forget zip runs for now

* Initialize ProxyDashboard on page load rather than within typescript i.e. on script load

* Enforce eslint with standard style

* Add .editorconfig to make editor compatible with various style requirements (Makefile, Typescript, Python)

* Remove extra empty line

* Add ability to pass headers with HttpRequestRejected exception, also remove proxy agent header for HttpRequestRejected

* Add ability to pass headers with HttpRequestRejected exception, also remove proxy agent header for HttpRequestRejected

* Fix tests

* Move common code under common sub-module

* Move flags under common module

* Move acceptor under core

* Move connection under core submodule

* Move chunk_parser under http

* Move http_parser as http/parser

* Move http_methods as http/methods

* Move http_proxy as http/proxy

* Move web_server as http/server

* Move status_codes as http/codes

* move websocket as http/websocket

* Move exception under http/exception, also move http/proxy exceptions under http/exceptions

* move protocol_handler as http/handler

* move devtools as http/devtools

* Move version under common/version

* Lifecycle if now core Event

* autopep8

* Add core event queue

* Register / unregister handler

* Enable inspection support for frontend dashboard

* Dont give an illusion of exception for HttpProtocolExceptions

* Update readme for refactored codebase

* DictQueueType everywhere

* Move all websocket API related code under WebsocketApi class

* Inspection enabled on tab switch.

1. Additionally now acceptors are assigned an int id.
2. Fix tests to match change in constructor.

* Corresponding ends of the work queues can be closed immediately.

Since work queues between AcceptorPool and Acceptor process is used only
once, close corresponding ends asap instead of at shutdown.

* No need of a manager for shared multiprocess Lock.

This unnecessarily creates additional manager process.

* Move threadless into its own module

* Merge acceptor and acceptor_pool tests

* Defer os.close

* Change content display with tab clicks.

Also ensure relay manager shutdown.

* Remove --cov flags

* Use right type for SyncManager

* Ensure coverage again

* Print help to discover flags, --cov certainly not available on Travis for some reason

* Add pytest-cov to requirements-testing

* Re-add windows on .travis also add changelog to readme

* Use 3.7 and no pip upgrade since it fails on travis windows

* Attempt to fix pip install on windows

* Disable windows on travis, it fails and uses 3.8.  Try reporting coverage from github actions

* Move away from coveralls, use codecov

* Codecov app installation either didnt work or token still needs to be passed

* Remove travis CI

* Use https://github.com/codecov/codecov-action for coverage uploads

* Remove run codecov

* Ha, codecov action only works on linux, what a mess

* Add cookie.js though unable to use it with es5/es6 modules yet

* Enable testing for python 3.8 also Build dashboard during testing

* No python 3.8 on github actions yet

* Autopep8

* Add separate workflows for library (python) and dashboard (node) app

* Type jobs not job

* Add checkout

* Fix parsing node version

* Fix dashboard build on windows

* Show codecov instead of coveralls
2019-10-28 14:57:33 -07:00
Abhinav Singh 3b9587b6f1
Ensure explicit flush before upgrade while TLS intercepting (#121)
* Ensure explicit flush before upgrade + nonblocking server sock.

* tls interception tests

* prepare for v1.1.1

* Add requirements.txt for typing extensions

* Add setup.py under lint workflow
2019-10-10 15:15:27 -07:00
Abhinav Singh 7a6247ea18 v1.1.0 release
Add pip install typing-extensions==3.7.4 for docker image
2019-10-10 00:29:41 -07:00
Abhinav Singh a9c8659ffa
Use selectors.DefaultSelector instead of select.select (#106)
* Use selectors.DefaultSelector instead of select.select

* Unregister to avoid endless loop

* Cleanup event register/unregiter

* Cleanup event registration

* Add google-fluentd.conf.  Use if running proxy.py on Google Cloud.

* Send server error from proxy if for whatever reason we fail to process the request (or should it be BadRequest based upon situation?)

* Fix tests for selectors

* Only include proxy.py and tests.py in coverage report

* Only include proxy.py for coverage

* remove redundant integration test, will rewrite using mocks

* Proper unregister of events

* Change multi core accept model to avoid client TIME_WAIT. Fixes #97

* Catch BlockingIOError

* Remove redundant comments

* Simplify with AcceptorPool

* Pass family to acceptor processes

* Remove plugin.access_log for core plugins

* Return 501 not implemented for web socket upgrade requests to inbuilt HTTP server

* Add support for websocket upgrade

* Websocket frame parser

* Enable websocket based routing

* Add WebsocketClient

* Websocket

* mypy fixes

* Sync GitHub workflow lint and makefile lint commands.

For now comment out tests which are broken :(  New tests coming next.

* Start fixing tests for new code

* Fix formatting

* Fix main tests

* Add worker tests

* GitHub only ran windows tests, may be require unique names

* Use 3.6/3.7 dev versions for GitHub actions

* Add AcceptorPool test

* Add x64 and x86 matrix for actions tests

* Dont use dev versions since they dont exists for x86

* Ha no x86 support itself

* Add backer link

* Remove support badge for 3.5 as it doesnt support typing

* Update read me with changed architecture notes

* Update read me with changed architecture notes

* Add `import proxy` usage instructions.

* Add pydoc reference for developers

* Put pydoc as internal documentation
2019-10-02 00:09:35 -07:00
Abhinav Singh 032a6f26c9 Make pypi release 1.0.0 2019-09-27 13:42:53 -07:00
Abhinav Singh ae1f1d654c
mypy coverage (#78)
* mypy coverage

* First stab at mypy --strict complaince

* mypy --strict compliance.

* Run mypy during Quality Check phase
2019-09-22 21:11:55 -07:00
Abhinav Singh 3bf0f0754b v1.0 2019-08-26 10:54:19 -07:00
Abhinav Singh 6dc01c6674 Add placeholder test for issue#5, prepare for v0.3 2018-12-10 21:40:12 +05:30
Abhinav Singh 5383abf195 PEP8 formatting 2018-10-17 14:01:19 +05:30
Abhinav Singh ea33c0e2c9 Prepare for v0.2 release
- Fix for None:None access log messages which essentially happen when client
closes a connection without making any request over it.
- Better log messages
- Fix setup.py for single file module
2015-03-17 12:30:25 -07:00
podhmo b1b19f70cf oops 2015-02-25 20:56:31 +09:00
Abhinav Singh 7d8a37ab34 setup.py and argparse 2013-08-20 14:56:32 +05:30