mirror of
https://github.com/zhigang1992/mitmproxy.git
synced 2026-04-07 22:40:04 +08:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be19ac8be6 | ||
|
|
d0411a62ee | ||
|
|
c4e643d3bd | ||
|
|
6ae378aa20 | ||
|
|
141897c7fc | ||
|
|
c78ffbf16d | ||
|
|
51d57cfd4a | ||
|
|
0bde932b78 | ||
|
|
38198769eb | ||
|
|
2735338815 | ||
|
|
4b1224e592 |
@@ -7,6 +7,9 @@ environment:
|
||||
matrix:
|
||||
- PYTHON: "C:\\Python35"
|
||||
TOXENV: "py35"
|
||||
# TODO: ENABLE WHEN AVAILABLE
|
||||
# - PYTHON: "C:\\Python36"
|
||||
# TOXENV: "py36"
|
||||
|
||||
SNAPSHOT_HOST:
|
||||
secure: NeTo57s2rJhCd/mjKHetXVxCFd3uhr8txnjnAXD1tUI=
|
||||
|
||||
10
.travis.yml
10
.travis.yml
@@ -31,6 +31,16 @@ matrix:
|
||||
- debian-sid
|
||||
packages:
|
||||
- libssl-dev
|
||||
- python: 3.6
|
||||
env: TOXENV=py36 OPENSSL_ALPN
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
# Debian sid currently holds OpenSSL 1.1.0
|
||||
# change this with future releases!
|
||||
- debian-sid
|
||||
packages:
|
||||
- libssl-dev
|
||||
- python: 3.5
|
||||
env: TOXENV=docs
|
||||
git:
|
||||
|
||||
7
dev.ps1
7
dev.ps1
@@ -1,7 +1,12 @@
|
||||
$ErrorActionPreference = "Stop"
|
||||
$VENV = ".\venv"
|
||||
|
||||
python3 -m venv $VENV --copies
|
||||
$pyver = python --version
|
||||
if($pyver -notmatch "3\.[5-9]") {
|
||||
Write-Warning "Unexpected Python version, expected Python 3.5 or above: $pyver"
|
||||
}
|
||||
|
||||
python -m venv $VENV --copies
|
||||
& $VENV\Scripts\activate.ps1
|
||||
|
||||
python -m pip install --disable-pip-version-check -U pip
|
||||
|
||||
2
dev.sh
2
dev.sh
@@ -2,7 +2,7 @@
|
||||
set -e
|
||||
set -x
|
||||
|
||||
PYVERSION=3.5
|
||||
PYVERSION=${1:-3.5}
|
||||
VENV="venv$PYVERSION"
|
||||
|
||||
echo "Creating dev environment in $VENV using Python $PYVERSION"
|
||||
|
||||
@@ -6,6 +6,8 @@ with a console interface.
|
||||
|
||||
**mitmdump** is the command-line version of mitmproxy. Think tcpdump for HTTP.
|
||||
|
||||
**mitmweb** is a web-based interface for mitmproxy.
|
||||
|
||||
Documentation, tutorials and distribution packages can be found on the
|
||||
mitmproxy website: `mitmproxy.org <https://mitmproxy.org/>`_
|
||||
|
||||
|
||||
@@ -21,8 +21,16 @@ def check_type(attr_name: str, value: typing.Any, typeinfo: type) -> None:
|
||||
type(value)
|
||||
))
|
||||
|
||||
if typeinfo.__qualname__ == "Union":
|
||||
for T in typeinfo.__union_params__:
|
||||
typename = str(typeinfo)
|
||||
|
||||
if typename.startswith("typing.Union"):
|
||||
try:
|
||||
types = typeinfo.__args__
|
||||
except AttributeError:
|
||||
# Python 3.5.x
|
||||
types = typeinfo.__union_params__
|
||||
|
||||
for T in types:
|
||||
try:
|
||||
check_type(attr_name, value, T)
|
||||
except TypeError:
|
||||
@@ -30,23 +38,35 @@ def check_type(attr_name: str, value: typing.Any, typeinfo: type) -> None:
|
||||
else:
|
||||
return
|
||||
raise e
|
||||
elif typeinfo.__qualname__ == "Tuple":
|
||||
elif typename.startswith("typing.Tuple"):
|
||||
try:
|
||||
types = typeinfo.__args__
|
||||
except AttributeError:
|
||||
# Python 3.5.x
|
||||
types = typeinfo.__tuple_params__
|
||||
|
||||
if not isinstance(value, (tuple, list)):
|
||||
raise e
|
||||
if len(typeinfo.__tuple_params__) != len(value):
|
||||
if len(types) != len(value):
|
||||
raise e
|
||||
for i, (x, T) in enumerate(zip(value, typeinfo.__tuple_params__)):
|
||||
for i, (x, T) in enumerate(zip(value, types)):
|
||||
check_type("{}[{}]".format(attr_name, i), x, T)
|
||||
return
|
||||
elif typeinfo.__qualname__ == "Sequence":
|
||||
T = typeinfo.__args__[0]
|
||||
elif typename.startswith("typing.Sequence"):
|
||||
try:
|
||||
T = typeinfo.__args__[0]
|
||||
except AttributeError:
|
||||
# Python 3.5.0
|
||||
T = typeinfo.__parameters__[0]
|
||||
if not isinstance(value, (tuple, list)):
|
||||
raise e
|
||||
for v in value:
|
||||
check_type(attr_name, v, T)
|
||||
elif typeinfo.__qualname__ == "IO":
|
||||
elif typename.startswith("typing.IO"):
|
||||
if hasattr(value, "read"):
|
||||
return
|
||||
else:
|
||||
raise e
|
||||
elif not isinstance(value, typeinfo):
|
||||
raise e
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
IVERSION = (1, 0, 0)
|
||||
IVERSION = (1, 0, 2)
|
||||
VERSION = ".".join(str(i) for i in IVERSION)
|
||||
PATHOD = "pathod " + VERSION
|
||||
MITMPROXY = "mitmproxy " + VERSION
|
||||
|
||||
1
setup.py
1
setup.py
@@ -35,6 +35,7 @@ setup(
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3 :: Only",
|
||||
"Programming Language :: Python :: 3.5",
|
||||
"Programming Language :: Python :: 3.6",
|
||||
"Programming Language :: Python :: Implementation :: CPython",
|
||||
"Programming Language :: Python :: Implementation :: PyPy",
|
||||
"Topic :: Security",
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import pytest
|
||||
import sys
|
||||
|
||||
from mitmproxy.test import tutils
|
||||
from mitmproxy.net.http import url
|
||||
|
||||
@@ -42,14 +45,18 @@ def test_parse():
|
||||
# Null byte in host
|
||||
with tutils.raises(ValueError):
|
||||
url.parse("http://foo\0")
|
||||
# Port out of range
|
||||
_, _, port, _ = url.parse("http://foo:999999")
|
||||
assert port == 80
|
||||
# Invalid IPv6 URL - see http://www.ietf.org/rfc/rfc2732.txt
|
||||
with tutils.raises(ValueError):
|
||||
url.parse('http://lo[calhost')
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.version_info < (3, 6), reason='requires Python 3.6 or higher')
|
||||
def test_parse_port_range():
|
||||
# Port out of range
|
||||
with tutils.raises(ValueError):
|
||||
url.parse("http://foo:999999")
|
||||
|
||||
|
||||
def test_unparse():
|
||||
assert url.unparse("http", "foo.com", 99, "") == "http://foo.com:99"
|
||||
assert url.unparse("http", "foo.com", 80, "/bar") == "http://foo.com/bar"
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import io
|
||||
import typing
|
||||
|
||||
import mock
|
||||
import pytest
|
||||
|
||||
from mitmproxy.utils import typecheck
|
||||
|
||||
|
||||
@@ -57,3 +60,17 @@ def test_check_sequence():
|
||||
typecheck.check_type("foo", [10, "foo"], typing.Sequence[int])
|
||||
with pytest.raises(TypeError):
|
||||
typecheck.check_type("foo", [b"foo"], typing.Sequence[str])
|
||||
with pytest.raises(TypeError):
|
||||
typecheck.check_type("foo", "foo", typing.Sequence[str])
|
||||
|
||||
# Python 3.5.0 only defines __parameters__
|
||||
m = mock.Mock()
|
||||
m.__str__ = lambda self: "typing.Sequence"
|
||||
m.__parameters__ = (int,)
|
||||
typecheck.check_type("foo", [10], m)
|
||||
|
||||
|
||||
def test_check_io():
|
||||
typecheck.check_type("foo", io.StringIO(), typing.IO[str])
|
||||
with pytest.raises(TypeError):
|
||||
typecheck.check_type("foo", "foo", typing.IO[str])
|
||||
|
||||
7
tox.ini
7
tox.ini
@@ -1,10 +1,9 @@
|
||||
[tox]
|
||||
envlist = py35, docs, lint
|
||||
envlist = py35, py36, docs, lint
|
||||
skipsdist = True
|
||||
toxworkdir={env:TOX_WORK_DIR:.tox}
|
||||
|
||||
[testenv]
|
||||
basepython = python3.5
|
||||
deps =
|
||||
{env:CI_DEPS:}
|
||||
-rrequirements.txt
|
||||
@@ -52,6 +51,8 @@ deps =
|
||||
# The 3.2 release is broken 🎉
|
||||
# the next commit after this updates the bootloaders, which then segfault! 🎉
|
||||
# https://github.com/pyinstaller/pyinstaller/issues/2232
|
||||
git+https://github.com/pyinstaller/pyinstaller.git@483c819d6a256b58db6740696a901bd41c313f0c
|
||||
git+https://github.com/pyinstaller/pyinstaller.git@483c819d6a256b58db6740696a901bd41c313f0c; sys_platform == 'win32'
|
||||
git+https://github.com/mhils/pyinstaller.git@d094401e4196b1a6a03818b80164a5f555861cef; sys_platform != 'win32'
|
||||
|
||||
commands =
|
||||
rtool {posargs}
|
||||
|
||||
Reference in New Issue
Block a user