Skip to content

Commit

Permalink
Merge pull request #64 from abhinavsingh/develop
Browse files Browse the repository at this point in the history
v0.3 -> v1.0
  • Loading branch information
abhinavsingh committed Sep 27, 2019
2 parents 3b59ade + 032a6f2 commit b34c720
Show file tree
Hide file tree
Showing 20 changed files with 3,696 additions and 936 deletions.
26 changes: 4 additions & 22 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
.coverage
.dockerignore
.git
.gitignore
.idea
.project
.settings
.pydevproject
# Ignore everything
**

__pycache__
*.pem
*.pyc
venv
cover
dist
proxy.py.egg-info

LICENSE
MANIFEST.in
README.md
Makefile
setup.py
tests.py
# Except proxy.py
!proxy.py
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
open_collective: proxypy
35 changes: 35 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Proxy.py

on: [push]

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macOS-latest, ubuntu-latest, windows-latest]
python: [3.6, 3.7]
max-parallel: 4
fail-fast: false
steps:
- uses: actions/checkout@v1
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python }}
architecture: x64
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-testing.txt
- name: Quality Check
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 proxy.py tests.py --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 proxy.py tests.py --count --exit-zero --max-line-length=127 --statistics
# mypy compliance check
mypy --strict --ignore-missing-imports proxy.py plugin_examples.py tests.py
- name: Run Tests
run: |
pytest tests.py
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
.project
.pydevproject
.settings
*.pyc
.mypy_cache
venv
cover
htmlcov
dist
build
proxy.py.egg-info
proxy.py.iml
*.pyc
*.pem
26 changes: 26 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
language: python
env:
- TESTING_ON_TRAVIS=1
matrix:
include:
- name: "Python 3.7 on Xenial Linux"
python: 3.7
- name: "Python 3.7 on macOS"
os: osx
osx_image: xcode11
language: shell
python: 3.7
- name: "Python 3.7 on Windows"
os: windows
language: shell
before_install:
- choco install python
- python -m pip install --upgrade pip
env:
- PATH=/c/Python37:/c/Python37/Scripts:$PATH
- TESTING_ON_TRAVIS=1
install:
- pip3 install -r requirements-testing.txt
script: python3 -m coverage run tests.py || python -m coverage run tests.py
after_success:
- coveralls
13 changes: 3 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
FROM python:3-alpine
LABEL com.abhinavsingh.name="abhinavsingh/proxy.py" \
com.abhinavsingh.description="Lightweight HTTP, HTTPS, WebSockets Proxy Server in a single Python file" \
# com.abhinavsingh.build-date="" \
com.abhinavsingh.description="Lightweight Programmable HTTP, HTTPS, WebSockets Proxy Server in a single Python file." \
com.abhinavsingh.url="https://github.com/abhinavsingh/proxy.py" \
com.abhinavsingh.vcs-url="https://github.com/abhinavsingh/proxy.py" \
# com.abhinavsingh.vcs-ref="" \
com.abhinavsingh.docker.cmd="docker run -it --rm -p 8899:8899 abhinavsingh/proxy.py"

COPY proxy.py /app/
EXPOSE 8899/tcp

WORKDIR /app
ENTRYPOINT [ "./proxy.py" ]
CMD [ "--host=0.0.0.0", \
"--port=8899", \
"--backlog=100", \
"--server-recvbuf-size=8192", \
"--client-recvbuf-size=8192", \
"--open-file-limit=1024", \
"--log-level=INFO" ]
CMD [ "--hostname=0.0.0.0", \
"--port=8899" ]
49 changes: 22 additions & 27 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,32 +1,27 @@
Copyright (c) 2013-2018 by Abhinav Singh and contributors.
Copyright (c) 2013-2020 by Abhinav Singh and contributors.
All rights reserved.

Some rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

Redistribution and use in source and binary forms of the software as well
as documentation, with or without modification, are permitted provided
that the following conditions are met:
- Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
- Neither the name of Abhinav Singh nor the names of its contributors may
be used to endorse or promote products derived from this software without
specific prior written permission.

* The names of the contributors may not be used to endorse or
promote products derived from this software without specific
prior written permission.

THIS SOFTWARE AND DOCUMENTATION IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE AND DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
include LICENSE
include README.md
include README.md
58 changes: 47 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,19 @@ SHELL := /bin/bash

NS ?= abhinavsingh
IMAGE_NAME ?= proxy.py
VERSION ?= v0.3
VERSION ?= v$(shell python proxy.py --version)
LATEST_TAG := $(NS)/$(IMAGE_NAME):latest
IMAGE_TAG := $(NS)/$(IMAGE_NAME):$(VERSION)

.PHONY: all clean test package test-release release coverage flake8 container
HTTPS_KEY_FILE_PATH := https-key.pem
HTTPS_CERT_FILE_PATH := https-cert.pem

CA_KEY_FILE_PATH := ca-key.pem
CA_CERT_FILE_PATH := ca-cert.pem
CA_SIGNING_KEY_FILE_PATH := ca-signing-key.pem

.PHONY: all clean test package test-release release coverage lint autopep8
.PHONY: container run-container release-container https-certificates ca-certificates

all: clean test

Expand All @@ -14,28 +23,55 @@ clean:
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
rm -f .coverage
rm -rf htmlcov
rm -rf dist
rm -rf htmlcov dist build

test:
python tests.py -v
python -m unittest tests

package: clean
python setup.py sdist bdist_wheel

test-release: package
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
twine upload --verbose --repository-url https://test.pypi.org/legacy/ dist/*

release: package
twine upload dist/*

coverage:
coverage run tests.py
coverage html
coverage3 run tests.py
coverage3 html
open htmlcov/index.html

flake8:
flake8 --ignore=E501,W504 --builtins="unicode" proxy.py
lint:
mypy --strict --ignore-missing-imports proxy.py plugin_examples.py tests.py
flake8 --ignore=E501,W504 proxy.py
flake8 --ignore=E501,W504 tests.py

autopep8:
autopep8 --recursive --in-place --aggressive proxy.py
autopep8 --recursive --in-place --aggressive tests.py
autopep8 --recursive --in-place --aggressive plugin_examples.py

container:
docker build -t $(IMAGE_TAG) .
docker build -t $(LATEST_TAG) -t $(IMAGE_TAG) .

run-container:
docker run -it -p 8899:8899 --rm $(LATEST_TAG)

release-container:
docker push $(IMAGE_TAG)

https-certificates:
# Generate server key
openssl genrsa -out $(HTTPS_KEY_FILE_PATH) 2048
# Generate server certificate
openssl req -new -x509 -days 3650 -key $(HTTPS_KEY_FILE_PATH) -out $(HTTPS_CERT_FILE_PATH)

ca-certificates:
# Generate CA key
openssl genrsa -out $(CA_KEY_FILE_PATH) 2048
# Generate CA certificate
openssl req -new -x509 -days 3650 -key $(CA_KEY_FILE_PATH) -out $(CA_CERT_FILE_PATH)
# Generate key that will be used to generate domain certificates on the fly
# Generated certificates are then signed with CA certificate / key generated above
openssl genrsa -out $(CA_SIGNING_KEY_FILE_PATH) 2048
2 changes: 2 additions & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# See https://devcenter.heroku.com/articles/procfile
web: python3 proxy.py --hostname 0.0.0.0 --port $PORT
Binary file added ProxyPy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit b34c720

Please sign in to comment.