11[ ![ Proxy.Py] ( https://raw.githubusercontent.com/abhinavsingh/proxy.py/develop/ProxyPy.png )] ( https://github.com/abhinavsingh/proxy.py )
22
33[ ![ License] ( https://img.shields.io/github/license/abhinavsingh/proxy.py.svg )] ( https://opensource.org/licenses/BSD-3-Clause )
4- [ ![ Build Status] ( https://travis-ci.org/abhinavsingh/proxy.py.svg?branch=develop )] ( https://travis-ci.org/abhinavsingh/proxy.py/ )
5- [ ![ No Dependencies] ( https://img.shields.io/static/v1?label=dependencies&message=none&color=green )] ( https://github.com/abhinavsingh/proxy.py )
64[ ![ PyPi Monthly] ( https://img.shields.io/pypi/dm/proxy.py.svg?color=green )] ( https://pypi.org/project/proxy.py/ )
75[ ![ Docker Pulls] ( https://img.shields.io/docker/pulls/abhinavsingh/proxy.py?color=green )] ( https://hub.docker.com/r/abhinavsingh/proxy.py )
6+ [ ![ No Dependencies] ( https://img.shields.io/static/v1?label=dependencies&message=none&color=green )] ( https://github.com/abhinavsingh/proxy.py )
7+
8+ [ ![ Proxy.py Library Build Status] ( https://github.com/abhinavsingh/proxy.py/workflows/Proxy.py%20Library/badge.svg )] ( https://github.com/abhinavsingh/proxy.py/actions )
9+ [ ![ Proxy.py Docker Build Status] ( https://github.com/abhinavsingh/proxy.py/workflows/Proxy.py%20Docker/badge.svg )] ( https://github.com/abhinavsingh/proxy.py/actions )
10+ [ ![ Proxy.py Docker Build Status] ( https://github.com/abhinavsingh/proxy.py/workflows/Proxy.py%20Dashboard/badge.svg )] ( https://github.com/abhinavsingh/proxy.py/actions )
11+ [ ![ Proxy.py Docker Build Status] ( https://github.com/abhinavsingh/proxy.py/workflows/Proxy.py%20Brew/badge.svg )] ( https://github.com/abhinavsingh/proxy.py/actions )
812[ ![ Coverage] ( https://codecov.io/gh/abhinavsingh/proxy.py/branch/develop/graph/badge.svg )] ( https://codecov.io/gh/abhinavsingh/proxy.py )
913
1014[ ![ Tested With MacOS, Ubuntu, Windows, Android, Android Emulator, iOS, iOS Simulator] ( https://img.shields.io/static/v1?label=tested%20with&message=mac%20OS%20%F0%9F%92%BB%20%7C%20Ubuntu%20%F0%9F%96%A5%20%7C%20Windows%20%F0%9F%92%BB&color=brightgreen )] ( https://abhinavsingh.com/proxy-py-a-lightweight-single-file-http-proxy-server-in-python/ )
@@ -84,10 +88,11 @@ Table of Contents
8488 * [ Http] ( #http-client )
8589 * [ build_http_request] ( #build_http_request )
8690 * [ build_http_response] ( #build_http_response )
87- * [ Websocket ] ( #websocket )
88- * [ WebsocketFrame ] ( #websocketframe )
89- * [ WebsocketClient ] ( #websocketclient )
91+ * [ Public Key Infrastructure ] ( #pki )
92+ * [ API Usage ] ( #api-usage )
93+ * [ CLI Usage ] ( #cli-usage )
9094* [ Frequently Asked Questions] ( #frequently-asked-questions )
95+ * [ Threads vs Threadless] ( #threads-vs-threadless )
9196 * [ SyntaxError: invalid syntax] ( #syntaxerror-invalid-syntax )
9297 * [ Unable to load plugins] ( #unable-to-load-plugins )
9398 * [ Unable to connect with proxy.py from remote host] ( #unable-to-connect-with-proxypy-from-remote-host )
@@ -1157,7 +1162,7 @@ Utilities
11571162
11581163# # TCP Sockets
11591164
1160- # ### new_socket_connection
1165+ # ## new_socket_connection
11611166
11621167Attempts to create an IPv4 connection, then IPv6 and
11631168finally a dual stack connection to provided address.
@@ -1168,7 +1173,7 @@ finally a dual stack connection to provided address.
11681173>>> conn.close ()
11691174` ` `
11701175
1171- # ### socket_connection
1176+ # ## socket_connection
11721177
11731178` socket_connection` is a convenient decorator + context manager
11741179around ` new_socket_connection` which ensures ` conn.close` is implicit.
@@ -1190,17 +1195,17 @@ As a decorator:
11901195
11911196# # Http Client
11921197
1193- # ### build_http_request
1198+ # ## build_http_request
11941199
1195- # #### Generate HTTP GET request
1200+ # ### Generate HTTP GET request
11961201
11971202` ` ` python
11981203>>> build_http_request(b' GET' , b' /' )
11991204b' GET / HTTP/1.1\r\n\r\n'
12001205>>>
12011206` ` `
12021207
1203- # #### Generate HTTP GET request with headers
1208+ # ### Generate HTTP GET request with headers
12041209
12051210` ` ` python
12061211>>> build_http_request(b' GET' , b' /' ,
@@ -1209,7 +1214,7 @@ b'GET / HTTP/1.1\r\nConnection: close\r\n\r\n'
12091214>>>
12101215` ` `
12111216
1212- # #### Generate HTTP POST request with headers and body
1217+ # ### Generate HTTP POST request with headers and body
12131218
12141219` ` ` python
12151220>>> import json
@@ -1219,19 +1224,54 @@ b'GET / HTTP/1.1\r\nConnection: close\r\n\r\n'
12191224 b' POST /form HTTP/1.1\r\nContent-type: application/json\r\n\r\n{"email": "[email protected] "}' 12201225` ` `
12211226
1222- # ### build_http_response
1227+ # ## build_http_response
12231228
12241229TODO
12251230
1226- # # Websocket
1231+ # # PKI
12271232
1228- # ### WebsocketFrame
1233+ # ## API Usage
12291234
1230- TODO
1235+ # ### gen_private_key
1236+ # ### gen_public_key
1237+ # ### remove_passphrase
1238+ # ### gen_csr
1239+ # ### sign_csr
12311240
1232- # ### WebsocketClient
1241+ See [pki.py](https://github.com/abhinavsingh/proxy.py/blob/develop/proxy/common/pki.py) for
1242+ method parameters and [test_pki.py](https://github.com/abhinavsingh/proxy.py/blob/develop/tests/common/test_pki.py)
1243+ for usage examples.
12331244
1234- TODO
1245+ # ## CLI Usage
1246+
1247+ Use ` proxy.common.pki` module for:
1248+
1249+ 1) Generation of public and private keys
1250+ 2) Generating CSR requests
1251+ 3) Signing CSR requests using custom CA.
1252+
1253+ ` ` ` bash
1254+ python -m proxy.common.pki -h
1255+ usage: pki.py [-h] [--password PASSWORD] [--private-key-path PRIVATE_KEY_PATH]
1256+ [--public-key-path PUBLIC_KEY_PATH] [--subject SUBJECT]
1257+ action
1258+
1259+ proxy.py v2.1.0 : PKI Utility
1260+
1261+ positional arguments:
1262+ action Valid actions: remove_passphrase, gen_private_key,
1263+ gen_public_key, gen_csr, sign_csr
1264+
1265+ optional arguments:
1266+ -h, --help show this help message and exit
1267+ --password PASSWORD Password to use for encryption. Default: proxy.py
1268+ --private-key-path PRIVATE_KEY_PATH
1269+ Private key path
1270+ --public-key-path PUBLIC_KEY_PATH
1271+ Public key path
1272+ --subject SUBJECT Subject to use for public key generation. Default:
1273+ /CN=example.com
1274+ ` ` `
12351275
12361276# # Internal Documentation
12371277
@@ -1255,6 +1295,19 @@ FILE
12551295Frequently Asked Questions
12561296==========================
12571297
1298+ # # Threads vs Threadless
1299+
1300+ Pre v2.x, ` proxy.py` used to spawn new threads for handling
1301+ client requests.
1302+
1303+ Starting v2.x, ` proxy.py` added support for threadless execution of
1304+ client requests using ` asyncio` .
1305+
1306+ In future, threadless execution will be the default mode.
1307+
1308+ Till then if you are interested in trying it out,
1309+ start ` proxy.py` with ` --threadless` flag.
1310+
12581311# # SyntaxError: invalid syntax
12591312
12601313Make sure you are using ` Python 3` . Verify the version before running ` proxy.py` :
@@ -1373,7 +1426,7 @@ usage: proxy [-h] [--backlog BACKLOG] [--basic-auth BASIC_AUTH]
13731426 [--static-server-dir STATIC_SERVER_DIR] [--threadless]
13741427 [--timeout TIMEOUT] [--version]
13751428
1376- proxy.py v2.0 .0
1429+ proxy.py v2.1 .0
13771430
13781431optional arguments:
13791432 -h, --help show this help message and exit
0 commit comments