diff options
-rw-r--r-- | docs/dev/sslkeylogfile.rst | 1 | ||||
-rw-r--r-- | docs/howmitmproxy.rst | 8 | ||||
-rw-r--r-- | docs/mitmproxy.rst | 1 | ||||
-rw-r--r-- | docs/modd.conf | 6 | ||||
-rw-r--r-- | docs/scripting/mitmproxy.rst | 1 | ||||
-rw-r--r-- | mitmproxy/dump.py | 2 | ||||
-rw-r--r-- | mitmproxy/protocol/base.py | 2 | ||||
-rwxr-xr-x | release/rtool.py | 139 |
8 files changed, 72 insertions, 88 deletions
diff --git a/docs/dev/sslkeylogfile.rst b/docs/dev/sslkeylogfile.rst index 04b86cc4..cb1f8f09 100644 --- a/docs/dev/sslkeylogfile.rst +++ b/docs/dev/sslkeylogfile.rst @@ -8,6 +8,7 @@ connections both from and to the proxy. Key logging is enabled by setting the en :envvar:`SSLKEYLOGFILE` so that it points to a writable text file. Recent versions of WireShark can use these log files to decrypt packets. You can specify the key file path in WireShark via + :samp:`Edit -> Preferences -> Protocols -> SSL -> (Pre)-Master-Secret log filename`. Note that :envvar:`SSLKEYLOGFILE` is respected by other programs as well, e.g. Firefox and Chrome. diff --git a/docs/howmitmproxy.rst b/docs/howmitmproxy.rst index b0b187d3..93602afe 100644 --- a/docs/howmitmproxy.rst +++ b/docs/howmitmproxy.rst @@ -18,7 +18,7 @@ the client and the server is well defined, and usually reliable. In the simplest possible interaction with mitmproxy, a client connects directly to the proxy, and makes a request that looks like this: -.. code-block:: http +.. code-block:: none GET http://example.com/index.html HTTP/1.1 @@ -39,7 +39,7 @@ Explicit HTTPS The process for an explicitly proxied HTTPS connection is quite different. The client connects to the proxy and makes a request that looks like this: -.. code-block:: http +.. code-block:: none CONNECT example.com:443 HTTP/1.1 @@ -80,7 +80,7 @@ blush, it seems that the CONNECT request above gives us all we need - in this example, both of these values are "example.com". But what if the client had initiated the connection as follows: -.. code-block:: http +.. code-block:: none CONNECT 10.1.1.1:443 HTTP/1.1 @@ -169,7 +169,7 @@ form of a firewall on the same host as the proxy server - `iptables`_ on Linux o pf_ on OSX. Once the client has initiated the connection, it makes a vanilla HTTP request, which might look something like this: -.. code-block:: http +.. code-block:: none GET /index.html HTTP/1.1 diff --git a/docs/mitmproxy.rst b/docs/mitmproxy.rst index fa3b57c7..922a6540 100644 --- a/docs/mitmproxy.rst +++ b/docs/mitmproxy.rst @@ -4,7 +4,6 @@ mitmproxy ========= - **mitmproxy** is a console tool that allows interactive examination and modification of HTTP traffic. It differs from mitmdump in that all flows are kept in memory, which means that it's intended for taking and manipulating diff --git a/docs/modd.conf b/docs/modd.conf new file mode 100644 index 00000000..bc91238c --- /dev/null +++ b/docs/modd.conf @@ -0,0 +1,6 @@ +@build = ./_build + +** !_build/** ../netlib/**/*.py ../mitmproxy/**/*.py { + prep: sphinx-build -W -d @build/doctrees -b html . @build/html + daemon: devd -m @build/html +} diff --git a/docs/scripting/mitmproxy.rst b/docs/scripting/mitmproxy.rst index 1626eb5a..73450df5 100644 --- a/docs/scripting/mitmproxy.rst +++ b/docs/scripting/mitmproxy.rst @@ -1,4 +1,3 @@ -.. _mitmproxy: mitmproxy ========= diff --git a/mitmproxy/dump.py b/mitmproxy/dump.py index d7f076cf..7b4609b4 100644 --- a/mitmproxy/dump.py +++ b/mitmproxy/dump.py @@ -73,7 +73,7 @@ class DumpMaster(flow.FlowMaster): self.set_stream_large_bodies(options.stream_large_bodies) - if self.server.config.http2 and not tcp.HAS_ALPN: # pragma: no cover + if self.server and self.server.config.http2 and not tcp.HAS_ALPN: # pragma: no cover print("ALPN support missing (OpenSSL 1.0.2+ required)!\n" "HTTP/2 is disabled. Use --no-http2 to silence this warning.", file=sys.stderr) diff --git a/mitmproxy/protocol/base.py b/mitmproxy/protocol/base.py index a14066cd..41d47281 100644 --- a/mitmproxy/protocol/base.py +++ b/mitmproxy/protocol/base.py @@ -163,7 +163,7 @@ class ServerConnectionMixin(object): self.server_conn.finish() self.server_conn.close() self.channel.tell("serverdisconnect", self.server_conn) - self.server_conn = ServerConnection(address, source_address) + self.server_conn = ServerConnection(address, (source_address.host, 0)) def connect(self): """ diff --git a/release/rtool.py b/release/rtool.py index d01ee741..6177b3f3 100755 --- a/release/rtool.py +++ b/release/rtool.py @@ -34,7 +34,7 @@ else: RELEASE_DIR = join(os.path.dirname(os.path.realpath(__file__))) DIST_DIR = join(RELEASE_DIR, "dist") ROOT_DIR = os.path.normpath(join(RELEASE_DIR, "..")) -VERSION_FILE = join(ROOT_DIR, "netlib/netlib/version.py") +VERSION_FILE = join(ROOT_DIR, "netlib/version.py") BUILD_DIR = join(RELEASE_DIR, "build") PYINSTALLER_TEMP = join(BUILD_DIR, "pyinstaller") @@ -44,27 +44,14 @@ VENV_DIR = join(BUILD_DIR, "venv") VENV_PIP = join(VENV_DIR, VENV_BIN, "pip") VENV_PYINSTALLER = join(VENV_DIR, VENV_BIN, "pyinstaller") -ALL_PROJECTS = { - "netlib": { - "tools": [], - "dir": join(ROOT_DIR, "netlib"), - "python_version": "py2.py3" # this is the format in wheel filenames - }, - "pathod": { - "tools": ["pathod", "pathoc"], - "dir": join(ROOT_DIR, "pathod"), - "python_version": "py2" - }, - "mitmproxy": { - "tools": ["mitmproxy", "mitmdump", "mitmweb"], - "dir": join(ROOT_DIR, "mitmproxy"), - "python_version": "py2" - } +project = { + "name": "mitmproxy", + "tools": ["pathod", "pathoc", "mitmproxy", "mitmdump", "mitmweb"], + "dir": ROOT_DIR, + "python_version": "py2" } if platform.system() == "Windows": - ALL_PROJECTS["mitmproxy"]["tools"].remove("mitmproxy") - -projects = {} + project["tools"].remove("mitmproxy") def get_version(): @@ -84,7 +71,7 @@ def get_snapshot_version(): ) -def archive_name(project): +def archive_name(): platform_tag = { "Darwin": "osx", "Windows": "win32", @@ -95,18 +82,18 @@ def archive_name(project): else: ext = "tar.gz" return "{project}-{version}-{platform}.{ext}".format( - project=project, + project=project["name"], version=get_version(), platform=platform_tag, ext=ext ) -def wheel_name(project): +def wheel_name(): return "{project}-{version}-{py_version}-none-any.whl".format( - project=project, + project=project["name"], version=get_version(), - py_version=projects[project]["python_version"] + py_version=project["python_version"] ) @@ -136,16 +123,11 @@ def git(args): @click.group(chain=True) -@click.option( - '--project', '-p', - multiple=True, type=click.Choice(ALL_PROJECTS.keys()), default=ALL_PROJECTS.keys() -) -def cli(project): +def cli(): """ mitmproxy build tool """ - for name in project: - projects[name] = ALL_PROJECTS[name] + pass @cli.command("contributors") @@ -188,15 +170,15 @@ def wheels(): print("Building release...") if os.path.exists(DIST_DIR): shutil.rmtree(DIST_DIR) - for project, conf in projects.items(): - print("Creating wheel for %s ..." % project) - subprocess.check_call( - [ - "python", "./setup.py", "-q", - "bdist_wheel", "--dist-dir", DIST_DIR, - ], - cwd=conf["dir"] - ) + + print("Creating wheel for %s ..." % project["name"]) + subprocess.check_call( + [ + "python", "./setup.py", "-q", + "bdist_wheel", "--dist-dir", DIST_DIR, + ], + cwd=project["dir"] + ) print("Creating virtualenv for test install...") if os.path.exists(VENV_DIR): @@ -204,16 +186,14 @@ def wheels(): subprocess.check_call(["virtualenv", "-q", VENV_DIR]) with chdir(DIST_DIR): - for project, conf in projects.items(): - print("Installing %s..." % project) - subprocess.check_call([VENV_PIP, "install", "-q", wheel_name(project)]) + print("Installing %s..." % project["name"]) + subprocess.check_call([VENV_PIP, "install", "-q", wheel_name()]) print("Running binaries...") - for project, conf in projects.items(): - for tool in conf["tools"]: - tool = join(VENV_DIR, VENV_BIN, tool) - print("> %s --version" % tool) - print(subprocess.check_output([tool, "--version"])) + for tool in project["tools"]: + tool = join(VENV_DIR, VENV_BIN, tool) + print("> %s --version" % tool) + print(subprocess.check_output([tool, "--version"])) print("Virtualenv available for further testing:") print("source %s" % os.path.normpath(join(VENV_DIR, VENV_BIN, "activate"))) @@ -238,34 +218,33 @@ def bdist(ctx, use_existing_wheels, pyinstaller_version): print("Installing PyInstaller...") subprocess.check_call([VENV_PIP, "install", "-q", pyinstaller_version]) - for p, conf in projects.items(): - if conf["tools"]: - with Archive(join(DIST_DIR, archive_name(p))) as archive: - for tool in conf["tools"]: - spec = join(RELEASE_DIR, "specs/%s.spec" % tool) - print("Building %s binary..." % tool) - subprocess.check_call( - [ - VENV_PYINSTALLER, - "--clean", - "--workpath", PYINSTALLER_TEMP, - "--distpath", PYINSTALLER_DIST, - # This is PyInstaller, so setting a - # different log level obviously breaks it :-) - # "--log-level", "WARN", - spec - ] - ) - - # Test if it works at all O:-) - executable = join(PYINSTALLER_DIST, tool) - if platform.system() == "Windows": - executable += ".exe" - print("> %s --version" % executable) - subprocess.check_call([executable, "--version"]) - - archive.add(executable, os.path.basename(executable)) - print("Packed {}.".format(archive_name(p))) + if project["tools"]: + with Archive(join(DIST_DIR, archive_name())) as archive: + for tool in project["tools"]: + spec = join(RELEASE_DIR, "specs/%s.spec" % tool) + print("Building %s binary..." % tool) + subprocess.check_call( + [ + VENV_PYINSTALLER, + "--clean", + "--workpath", PYINSTALLER_TEMP, + "--distpath", PYINSTALLER_DIST, + # This is PyInstaller, so setting a + # different log level obviously breaks it :-) + # "--log-level", "WARN", + spec + ] + ) + + # Test if it works at all O:-) + executable = join(PYINSTALLER_DIST, tool) + if platform.system() == "Windows": + executable += ".exe" + print("> %s --version" % executable) + subprocess.check_call([executable, "--version"]) + + archive.add(executable, os.path.basename(executable)) + print("Packed {}.".format(archive_name())) @cli.command("upload-release") @@ -277,7 +256,7 @@ def upload_release(username, password, repository): Upload wheels to PyPI """ for project in projects.keys(): - filename = wheel_name(project) + filename = wheel_name() print("Uploading {} to {}...".format(filename, repository)) subprocess.check_call([ "twine", @@ -312,9 +291,9 @@ def upload_snapshot(host, port, user, private_key, private_key_password, wheel, with sftp.cd(dir_name): files = [] if wheel: - files.append(wheel_name(project)) + files.append(wheel_name()) if bdist and conf["tools"]: - files.append(archive_name(project)) + files.append(archive_name()) for f in files: local_path = join(DIST_DIR, f) |