Skip to content

Commit e827eaa

Browse files
authored
Merge pull request #282 from abhinavsingh/develop
proxy.py v2.1.2
2 parents cf6ab8b + 44f2984 commit e827eaa

26 files changed

+689
-365
lines changed

.github/workflows/test-brew.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Proxy.py Brew
22

3-
on: [push]
3+
on: [push, pull_request]
44

55
jobs:
66
build:

.github/workflows/test-dashboard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Proxy.py Dashboard
22

3-
on: [push]
3+
on: [push, pull_request]
44

55
jobs:
66
build:

.github/workflows/test-docker.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Proxy.py Docker
22

3-
on: [push]
3+
on: [push, pull_request]
44

55
jobs:
66
build:

.github/workflows/test-library.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Proxy.py Library
22

3-
on: [push]
3+
on: [push, pull_request]
44

55
jobs:
66
build:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ proxy.py.iml
1818
*.csr
1919
*.crt
2020
*.key
21+
*.pem
2122
venv*
2223

2324
cover

CODE_OF_CONDUCT.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to making participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, sex characteristics, gender identity and expression,
9+
level of experience, education, socio-economic status, nationality, personal
10+
appearance, race, religion, or sexual identity and orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
* Using welcoming and inclusive language
18+
* Being respectful of differing viewpoints and experiences
19+
* Gracefully accepting constructive criticism
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
* The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
* Trolling, insulting/derogatory comments, and personal or political attacks
28+
* Public or private harassment
29+
* Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
* Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies both within project spaces and in public spaces
49+
when an individual is representing the project or its community. Examples of
50+
representing a project or community include using an official project e-mail
51+
address, posting via an official social media account, or acting as an appointed
52+
representative at an online or offline event. Representation of a project may be
53+
further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team at [email protected]. All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72+
73+
[homepage]: https://www.contributor-covenant.org
74+
75+
For answers to common questions about this code of conduct, see
76+
https://www.contributor-covenant.org/faq

Makefile

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ CA_CERT_FILE_PATH := ca-cert.pem
1414
CA_SIGNING_KEY_FILE_PATH := ca-signing-key.pem
1515

1616
.PHONY: all https-certificates ca-certificates autopep8 devtools
17-
.PHONY: lib-clean lib-test lib-package lib-release-test lib-release lib-coverage lib-lint lib-profile
17+
.PHONY: lib-version lib-clean lib-test lib-package lib-coverage lib-lint
18+
.PHONY: lib-release-test lib-release lib-profile
1819
.PHONY: container container-run container-release
1920
.PHONY: dashboard dashboard-clean
2021

21-
all: lib-clean lib-test
22+
all: lib-test
2223

2324
devtools:
2425
pushd dashboard && npm run devtools && popd
@@ -30,18 +31,34 @@ autopep8:
3031

3132
https-certificates:
3233
# Generate server key
33-
openssl genrsa -out $(HTTPS_KEY_FILE_PATH) 2048
34+
python -m proxy.common.pki gen_private_key \
35+
--private-key-path $(HTTPS_KEY_FILE_PATH)
36+
python -m proxy.common.pki remove_passphrase \
37+
--private-key-path $(HTTPS_KEY_FILE_PATH)
3438
# Generate server certificate
35-
openssl req -new -x509 -days 3650 -key $(HTTPS_KEY_FILE_PATH) -out $(HTTPS_CERT_FILE_PATH)
39+
python -m proxy.common.pki gen_public_key \
40+
--private-key-path $(HTTPS_KEY_FILE_PATH) \
41+
--public-key-path $(HTTPS_CERT_FILE_PATH)
3642

3743
ca-certificates:
3844
# Generate CA key
39-
openssl genrsa -out $(CA_KEY_FILE_PATH) 2048
45+
python -m proxy.common.pki gen_private_key \
46+
--private-key-path $(CA_KEY_FILE_PATH)
47+
python -m proxy.common.pki remove_passphrase \
48+
--private-key-path $(CA_KEY_FILE_PATH)
4049
# Generate CA certificate
41-
openssl req -new -x509 -days 3650 -key $(CA_KEY_FILE_PATH) -out $(CA_CERT_FILE_PATH)
50+
python -m proxy.common.pki gen_public_key \
51+
--private-key-path $(CA_KEY_FILE_PATH) \
52+
--public-key-path $(CA_CERT_FILE_PATH)
4253
# Generate key that will be used to generate domain certificates on the fly
4354
# Generated certificates are then signed with CA certificate / key generated above
44-
openssl genrsa -out $(CA_SIGNING_KEY_FILE_PATH) 2048
55+
python -m proxy.common.pki gen_private_key \
56+
--private-key-path $(CA_SIGNING_KEY_FILE_PATH)
57+
python -m proxy.common.pki remove_passphrase \
58+
--private-key-path $(CA_SIGNING_KEY_FILE_PATH)
59+
60+
lib-version:
61+
python version-check.py
4562

4663
lib-clean:
4764
find . -name '*.pyc' -exec rm -f {} +
@@ -59,10 +76,10 @@ lib-lint:
5976
flake8 --ignore=W504 --max-line-length=127 --max-complexity=19 proxy/ tests/ setup.py
6077
mypy --strict --ignore-missing-imports proxy/ tests/ setup.py
6178

62-
lib-test: lib-lint
79+
lib-test: lib-clean lib-version lib-lint
6380
pytest -v tests/
6481

65-
lib-package: lib-clean
82+
lib-package: lib-clean lib-version
6683
python setup.py sdist
6784

6885
lib-release-test: lib-package

README.md

Lines changed: 71 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
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
11621167
Attempts to create an IPv4 connection, then IPv6 and
11631168
finally 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
11741179
around `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'/')
11991204
b'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
12241229
TODO
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
12551295
Frequently 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
12601313
Make 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
13781431
optional arguments:
13791432
-h, --help show this help message and exit

helper/homebrew/stable/proxy.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class Proxy < Formula
55
Network monitoring, controls & Application development, testing, debugging."
66
homepage "https://github.com/abhinavsingh/proxy.py"
77
url "https://github.com/abhinavsingh/proxy.py/archive/master.zip"
8-
version "1.1.1"
8+
version "2.0.0"
99

1010
depends_on "python"
1111

0 commit comments

Comments
 (0)