fix all libmproxy->mitmproxy references

This commit is contained in:
Thomas Kriechbaumer
2016-02-16 20:49:10 +01:00
parent f1a0a3b228
commit d95a1f9819
69 changed files with 175 additions and 177 deletions

4
.gitattributes vendored
View File

@@ -1,2 +1,2 @@
mitmproxy/libmproxy/web/static/**/* -diff
mitmproxy/web/src/js/filt/filt.js -diff
mitmproxy/mitmproxy/web/static/**/* -diff
mitmproxy/web/src/js/filt/filt.js -diff

View File

@@ -1,2 +1,2 @@
graft libmproxy
graft mitmproxy
recursive-exclude * *.pyc *.pyo *.swo *.swp *.map

View File

@@ -1,3 +1,3 @@
#!/usr/bin/env python
from libmproxy.main import mitmdump
from mitmproxy.main import mitmdump
mitmdump()

View File

@@ -1,3 +1,3 @@
#!/usr/bin/env python
from libmproxy.main import mitmproxy
from mitmproxy.main import mitmproxy
mitmproxy()

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
from libmproxy.main import mitmweb
from mitmproxy.main import mitmweb
mitmweb()

View File

@@ -192,4 +192,4 @@ pseudoxml:
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
livehtml:
sphinx-autobuild -b html -z '../libmproxy' -z '../../netlib/netlib' -r '___jb_(old|bak)___$$' $(ALLSPHINXOPTS) $(BUILDDIR)/html
sphinx-autobuild -b html -z '../mitmproxy' -z '../../netlib/netlib' -r '___jb_(old|bak)___$$' $(ALLSPHINXOPTS) $(BUILDDIR)/html

View File

@@ -21,7 +21,7 @@ import shlex
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.abspath('..'))
import libmproxy.version
import mitmproxy.version
# -- General configuration ------------------------------------------------
@@ -69,9 +69,9 @@ author = u'The mitmproxy project'
# built documents.
#
# The short X.Y version.
version = libmproxy.version.VERSION
version = mitmproxy.version.VERSION
# The full version, including alpha/beta/rc tags.
release = libmproxy.version.VERSION
release = mitmproxy.version.VERSION
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
@@ -109,7 +109,7 @@ exclude_patterns = ['_build']
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
modindex_common_prefix = ['libmproxy.']
modindex_common_prefix = ['mitmproxy.']
# If true, keep warnings as "system message" paragraphs in the built documents.
#keep_warnings = False

View File

@@ -3,7 +3,7 @@
Exceptions
==========
.. automodule:: libmproxy.exceptions
.. automodule:: mitmproxy.exceptions
:show-inheritance:
:members:
:undoc-members:

View File

@@ -54,6 +54,6 @@ Models
.. autoclass:: decoded
.. automodule:: libmproxy.models
.. automodule:: mitmproxy.models
:show-inheritance:
:members: HTTPFlow, Error, ClientConnection, ServerConnection

View File

@@ -3,7 +3,7 @@
Protocols
=========
.. automodule:: libmproxy.protocol
.. automodule:: mitmproxy.protocol
.. autoclass:: Layer
:members:

View File

@@ -3,7 +3,7 @@
Proxy Server
============
.. automodule:: libmproxy.proxy
.. automodule:: mitmproxy.proxy
.. autoclass:: ProxyServer
.. autoclass:: DummyServer

View File

@@ -10,7 +10,7 @@ suitable extension to the test suite.
Our tests are written for the `py.test`_ or nose_ test frameworks.
At the point where you send your pull request, a command like this:
>>> py.test -n 4 --cov libmproxy
>>> py.test -n 4 --cov mitmproxy
Should give output something like this:
@@ -19,18 +19,18 @@ Should give output something like this:
> ---------- coverage: platform darwin, python 2.7.2-final-0 --
> Name Stmts Miss Cover Missing
> ----------------------------------------------------
> libmproxy/__init__ 0 0 100%
> libmproxy/app 4 0 100%
> libmproxy/cmdline 100 0 100%
> libmproxy/controller 69 0 100%
> libmproxy/dump 150 0 100%
> libmproxy/encoding 39 0 100%
> libmproxy/filt 201 0 100%
> libmproxy/flow 891 0 100%
> libmproxy/proxy 427 0 100%
> libmproxy/script 27 0 100%
> libmproxy/utils 133 0 100%
> libmproxy/version 4 0 100%
> mitmproxy/__init__ 0 0 100%
> mitmproxy/app 4 0 100%
> mitmproxy/cmdline 100 0 100%
> mitmproxy/controller 69 0 100%
> mitmproxy/dump 150 0 100%
> mitmproxy/encoding 39 0 100%
> mitmproxy/filt 201 0 100%
> mitmproxy/flow 891 0 100%
> mitmproxy/proxy 427 0 100%
> mitmproxy/script 27 0 100%
> mitmproxy/utils 133 0 100%
> mitmproxy/version 4 0 100%
> ----------------------------------------------------
> TOTAL 2045 0 100%
> ----------------------------------------------------

View File

@@ -8,7 +8,7 @@ Filter expressions consist of the following operators:
.. documentedlist::
:header: "Expression" "Description"
:listobject: libmproxy.filt.help
:listobject: mitmproxy.filt.help
- Regexes are Python-style
- Regexes can be specified as quoted strings

View File

@@ -236,4 +236,4 @@ explicit HTTPS connections to establish the CN and SANs, and cope with SNI.
.. _Subject Alternative Name: https://en.wikipedia.org/wiki/SubjectAltName
.. _iptables: http://www.netfilter.org/
.. _pf: https://en.wikipedia.org/wiki/PF_\(firewall\)
.. _modules: https://github.com/mitmproxy/mitmproxy/tree/master/libmproxy/platform
.. _modules: https://github.com/mitmproxy/mitmproxy/tree/master/mitmproxy/platform

View File

@@ -52,7 +52,7 @@
:caption: Scripting
scripting/inlinescripts
scripting/libmproxy
scripting/mitmproxy
.. toctree::

View File

@@ -6,8 +6,6 @@ with a console interface.
**mitmdump** is the command-line version of mitmproxy. Think tcpdump for HTTP.
**libmproxy** is the library that mitmproxy and mitmdump are built on.
Documentation, tutorials and distribution packages can be found on the
mitmproxy website: `mitmproxy.org <https://mitmproxy.org/>`_

View File

@@ -16,8 +16,8 @@ client:
:language: python
The first argument to each event method is an instance of
:py:class:`~libmproxy.script.ScriptContext` that lets the script interact with the global mitmproxy
state. The **response** event also gets an instance of :py:class:`~libmproxy.script.ScriptContext`,
:py:class:`~mitmproxy.script.ScriptContext` that lets the script interact with the global mitmproxy
state. The **response** event also gets an instance of :py:class:`~mitmproxy.script.ScriptContext`,
which we can use to manipulate the response itself.
We can now run this script using mitmdump or mitmproxy as follows:
@@ -37,7 +37,7 @@ Events
------
The ``context`` argument passed to each event method is always a
:py:class:`~libmproxy.script.ScriptContext` instance. It is guaranteed to be the same object
:py:class:`~mitmproxy.script.ScriptContext` instance. It is guaranteed to be the same object
for the scripts lifetime and is not shared between multiple inline scripts. You can safely use it
to store any form of state you require.
@@ -67,7 +67,7 @@ Connection Events
:param Layer root_layer: The root layer (see :ref:`protocols` for an explanation what the root
layer is), which provides transparent access to all attributes of the
:py:class:`~libmproxy.proxy.RootContext`. For example, ``root_layer.client_conn.address``
:py:class:`~mitmproxy.proxy.RootContext`. For example, ``root_layer.client_conn.address``
gives the remote address of the connecting client.
.. py:function:: clientdisconnect(context, root_layer)
@@ -155,32 +155,32 @@ The canonical API documentation is the code, which you can browse here, locally
The main classes you will deal with in writing mitmproxy scripts are:
:py:class:`~libmproxy.script.ScriptContext`
:py:class:`~mitmproxy.script.ScriptContext`
- A handle for interacting with mitmproxy's Flow Master from within scripts.
:py:class:`~libmproxy.models.ClientConnection`
:py:class:`~mitmproxy.models.ClientConnection`
- Describes a client connection.
:py:class:`~libmproxy.models.ServerConnection`
:py:class:`~mitmproxy.models.ServerConnection`
- Describes a server connection.
:py:class:`~libmproxy.models.HTTPFlow`
:py:class:`~mitmproxy.models.HTTPFlow`
- A collection of objects representing a single HTTP transaction.
:py:class:`~libmproxy.models.HTTPRequest`
:py:class:`~mitmproxy.models.HTTPRequest`
- An HTTP request.
:py:class:`~libmproxy.models.HTTPResponse`
:py:class:`~mitmproxy.models.HTTPResponse`
- An HTTP response.
:py:class:`~libmproxy.models.Error`
:py:class:`~mitmproxy.models.Error`
- A communications error.
:py:class:`netlib.http.Headers`
- A dictionary-like object for managing HTTP headers.
:py:class:`netlib.certutils.SSLCert`
- Exposes information SSL certificates.
:py:class:`libmproxy.flow.FlowMaster`
- The "heart" of libmproxy, usually subclassed as :py:class:`libmproxy.dump.DumpMaster` or
:py:class:`libmproxy.console.ConsoleMaster`.
:py:class:`mitmproxy.flow.FlowMaster`
- The "heart" of mitmproxy, usually subclassed as :py:class:`mitmproxy.dump.DumpMaster` or
:py:class:`mitmproxy.console.ConsoleMaster`.
Script Context
--------------
.. autoclass:: libmproxy.script.ScriptContext
.. autoclass:: mitmproxy.script.ScriptContext
:members:
:undoc-members:
@@ -189,7 +189,7 @@ Running scripts in parallel
We have a single flow primitive, so when a script is blocking, other requests are not processed.
While that's usually a very desirable behaviour, blocking scripts can be run threaded by using the
:py:obj:`libmproxy.script.concurrent` decorator.
:py:obj:`mitmproxy.script.concurrent` decorator.
**If your script does not block, you should avoid the overhead of the decorator.**
.. literalinclude:: ../../examples/nonblocking.py
@@ -210,7 +210,7 @@ The arguments are then exposed in the start event:
Running scripts on saved flows
------------------------------
Sometimes, we want to run a script on :py:class:`~libmproxy.models.Flow` objects that are already
Sometimes, we want to run a script on :py:class:`~mitmproxy.models.Flow` objects that are already
complete. This happens when you start a script, and then load a saved set of flows from a file
(see the "scripted data transformation" example `here <https://mitmproxy.org/doc/mitmdump.html>`_).
It also happens when you run a one-shot script on a single flow through the ``|`` (pipe) shortcut

View File

@@ -1,18 +1,18 @@
.. _libmproxy:
.. _mitmproxy:
libmproxy
mitmproxy
=========
.. note::
We strongly encourage you to use :ref:`inlinescripts` rather than libmproxy.
We strongly encourage you to use :ref:`inlinescripts` rather than mitmproxy.
- Inline Scripts are equally powerful and provide an easier syntax.
- Most examples are written as inline scripts.
- Multiple inline scripts can be used together.
- Inline Scripts can either be executed headless with mitmdump or within the mitmproxy UI.
All of mitmproxy's basic functionality is exposed through the **libmproxy**
All of mitmproxy's basic functionality is exposed through the **mitmproxy**
library. The example below shows a simple implementation of the "sticky cookie"
functionality included in the interactive mitmproxy program. Traffic is
monitored for ``Cookie`` and ``Set-Cookie`` headers, and requests are rewritten

View File

@@ -20,9 +20,9 @@ stub.py Script stub with a method definition for every event.
upsidedownternet.py Rewrites traffic to turn images upside down.
# libmproxy examples
# mitmproxy examples
flowbasic Basic use of mitmproxy as a library.
stickycookies An example of writing a custom proxy with libmproxy.
stickycookies An example of writing a custom proxy with mitmproxy.
# misc

View File

@@ -1,7 +1,7 @@
import string
import lxml.html
import lxml.etree
from libmproxy import utils, contentviews
from mitmproxy import utils, contentviews
class ViewPigLatin(contentviews.View):

View File

@@ -1,7 +1,7 @@
# This scripts demonstrates how to use mitmproxy's filter pattern in inline scripts.
# Usage: mitmdump -s "filt.py FILTER"
from libmproxy import filt
from mitmproxy import filt
def start(context, argv):

View File

@@ -8,8 +8,8 @@
Note that request and response messages are not automatically replied to,
so we need to implement handlers to do this.
"""
from libmproxy import flow
from libmproxy.proxy import ProxyServer, ProxyConfig
from mitmproxy import flow
from mitmproxy.proxy import ProxyServer, ProxyConfig
class MyMaster(flow.FlowMaster):

View File

@@ -1,7 +1,7 @@
import random
import sys
from libmproxy.flow import FlowWriter
from mitmproxy.flow import FlowWriter
def start(context, argv):

View File

@@ -1,7 +1,7 @@
# Usage: mitmdump -s "iframe_injector.py url"
# (this script works best with --anticache)
from bs4 import BeautifulSoup
from libmproxy.models import decoded
from mitmproxy.models import decoded
def start(context, argv):

View File

@@ -1,6 +1,6 @@
# Usage: mitmdump -s "modify_response_body.py mitmproxy bananas"
# (this script works best with --anticache)
from libmproxy.models import decoded
from mitmproxy.models import decoded
def start(context, argv):

View File

@@ -1,5 +1,5 @@
import time
from libmproxy.script import concurrent
from mitmproxy.script import concurrent
@concurrent # Remove this and see what happens

View File

@@ -3,7 +3,7 @@
# Simple script showing how to read a mitmproxy dump file
#
from libmproxy import flow
from mitmproxy import flow
import pprint
import sys

View File

@@ -1,7 +1,7 @@
"""
This example shows two ways to redirect flows to other destinations.
"""
from libmproxy.models import HTTPResponse
from mitmproxy.models import HTTPResponse
from netlib.http import Headers
def request(context, flow):

View File

@@ -6,8 +6,8 @@ implement functionality similar to the "sticky cookies" option.
Heads Up: In the majority of cases, you want to use inline scripts.
"""
import os
from libmproxy import controller, proxy
from libmproxy.proxy.server import ProxyServer
from mitmproxy import controller, proxy
from mitmproxy.proxy.server import ProxyServer
class StickyMaster(controller.Master):

View File

@@ -26,8 +26,8 @@ import random
from enum import Enum
from libmproxy.exceptions import TlsProtocolException
from libmproxy.protocol import TlsLayer, RawTCPLayer
from mitmproxy.exceptions import TlsProtocolException
from mitmproxy.protocol import TlsLayer, RawTCPLayer
class InterceptionResult(Enum):

View File

@@ -1,6 +1,6 @@
import cStringIO
from PIL import Image
from libmproxy.models import decoded
from mitmproxy.models import decoded
def response(context, flow):

View File

@@ -364,7 +364,7 @@ def proxy_options(parser):
)
http2 = group.add_mutually_exclusive_group()
# !!!
# Watch out: We raise a RuntimeError in libmproxy.proxy.config if http2 is enabled,
# Watch out: We raise a RuntimeError in mitmproxy.proxy.config if http2 is enabled,
# but the OpenSSL version does not have ALPN support (which is the default on Ubuntu 14.04).
# Do not simply set --http2 as enabled by default.
# !!!
@@ -642,7 +642,7 @@ def common_options(parser):
def mitmproxy():
# Don't import libmproxy.console for mitmdump, urwid is not available on all
# Don't import mitmproxy.console for mitmdump, urwid is not available on all
# platforms.
from .console import palettes

View File

@@ -11,7 +11,7 @@ from __future__ import (absolute_import, print_function, division)
class ProxyException(Exception):
"""
Base class for all exceptions thrown by libmproxy.
Base class for all exceptions thrown by mitmproxy.
"""
def __init__(self, message=None):

View File

@@ -5,10 +5,10 @@ import warnings
from email.utils import parsedate_tz, formatdate, mktime_tz
import time
from libmproxy import utils
from netlib import encoding
from netlib.http import status_codes, Headers, Request, Response, decoded
from netlib.tcp import Address
from .. import utils
from .. import version
from .flow import Flow

View File

@@ -18,7 +18,7 @@ Upgrade request. An actual mitmproxy connection may look as follows (outermost l
Every layer acts as a read-only context for its inner layers (see :py:class:`Layer`). To communicate
with an outer layer, a layer can use functions provided in the context. The next layer is always
determined by a call to :py:meth:`.next_layer() <libmproxy.proxy.RootContext.next_layer>`,
determined by a call to :py:meth:`.next_layer() <mitmproxy.proxy.RootContext.next_layer>`,
which is provided by the root context.
Another subtle design goal of this architecture is that upstream connections should be established

View File

@@ -19,15 +19,15 @@ class _LayerCodeCompletion(object):
if True:
return
self.config = None
"""@type: libmproxy.proxy.ProxyConfig"""
"""@type: mitmproxy.proxy.ProxyConfig"""
self.client_conn = None
"""@type: libmproxy.models.ClientConnection"""
"""@type: mitmproxy.models.ClientConnection"""
self.server_conn = None
"""@type: libmproxy.models.ServerConnection"""
"""@type: mitmproxy.models.ServerConnection"""
self.channel = None
"""@type: libmproxy.controller.Channel"""
"""@type: mitmproxy.controller.Channel"""
self.ctx = None
"""@type: libmproxy.protocol.Layer"""
"""@type: mitmproxy.protocol.Layer"""
class Layer(_LayerCodeCompletion):
@@ -48,9 +48,9 @@ class Layer(_LayerCodeCompletion):
sub_layer = Layer(root_layer)
print(sub_layer.client_conn) # 42
The root layer is passed a :py:class:`libmproxy.proxy.RootContext` object,
which provides access to :py:attr:`.client_conn <libmproxy.proxy.RootContext.client_conn>`,
:py:attr:`.next_layer <libmproxy.proxy.RootContext.next_layer>` and other basic attributes.
The root layer is passed a :py:class:`mitmproxy.proxy.RootContext` object,
which provides access to :py:attr:`.client_conn <mitmproxy.proxy.RootContext.client_conn>`,
:py:attr:`.next_layer <mitmproxy.proxy.RootContext.next_layer>` and other basic attributes.
Args:
ctx: The (read-only) parent layer / context.
@@ -70,7 +70,7 @@ class Layer(_LayerCodeCompletion):
Once the protocol has finished without exceptions.
Raises:
~libmproxy.exceptions.ProtocolException: if an exception occurs. No other exceptions must be raised.
~mitmproxy.exceptions.ProtocolException: if an exception occurs. No other exceptions must be raised.
"""
raise NotImplementedError()
@@ -138,7 +138,7 @@ class ServerConnectionMixin(object):
Sets a new server address. If there is an existing connection, it will be closed.
Raises:
~libmproxy.exceptions.ProtocolException:
~mitmproxy.exceptions.ProtocolException:
if ``server_tls`` is ``True``, but there was no TLS layer on the
protocol stack which could have processed this.
"""
@@ -171,7 +171,7 @@ class ServerConnectionMixin(object):
Must not be called if there is an existing connection.
Raises:
~libmproxy.exceptions.ProtocolException: if the connection could not be established.
~mitmproxy.exceptions.ProtocolException: if the connection could not be established.
"""
if not self.server_conn.address:
raise ProtocolException("Cannot connect to server, no server address given.")

View File

@@ -1,7 +1,7 @@
from __future__ import (absolute_import, print_function, division)
import threading
import traceback
from libmproxy.exceptions import ReplayException
from mitmproxy.exceptions import ReplayException
from netlib.exceptions import HttpException, TcpException
from netlib.http import http1
@@ -10,7 +10,7 @@ from ..models import Error, HTTPResponse, ServerConnection, make_connect_request
from .base import Kill
# TODO: Doesn't really belong into libmproxy.protocol...
# TODO: Doesn't really belong into mitmproxy.protocol...
class RequestReplayThread(threading.Thread):

View File

@@ -227,7 +227,7 @@ def get_client_hello(client_conn):
Peek into the socket and read all records that contain the initial client hello message.
client_conn:
The :py:class:`client connection <libmproxy.models.ClientConnection>`.
The :py:class:`client connection <mitmproxy.models.ClientConnection>`.
Returns:
The raw handshake packet bytes, without TLS record header(s).
@@ -279,9 +279,9 @@ class TlsClientHello(object):
"""
Peek into the connection, read the initial client hello and parse it to obtain ALPN values.
client_conn:
The :py:class:`client connection <libmproxy.models.ClientConnection>`.
The :py:class:`client connection <mitmproxy.models.ClientConnection>`.
Returns:
:py:class:`client hello <libmproxy.protocol.tls.TlsClientHello>`.
:py:class:`client hello <mitmproxy.protocol.tls.TlsClientHello>`.
"""
try:
raw_client_hello = get_client_hello(client_conn)[4:] # exclude handshake header.

View File

@@ -4,7 +4,7 @@ import sys
import six
from libmproxy.exceptions import ProtocolException, TlsProtocolException
from mitmproxy.exceptions import ProtocolException, TlsProtocolException
from netlib.exceptions import TcpException
from ..protocol import (
RawTCPLayer, TlsLayer, Http1Layer, Http2Layer, is_tls_record_magic, ServerConnectionMixin,
@@ -21,13 +21,13 @@ class RootContext(object):
Attributes:
client_conn:
The :py:class:`client connection <libmproxy.models.ClientConnection>`.
The :py:class:`client connection <mitmproxy.models.ClientConnection>`.
channel:
A :py:class:`~libmproxy.controller.Channel` to communicate with the FlowMaster.
Provides :py:meth:`.ask() <libmproxy.controller.Channel.ask>` and
:py:meth:`.tell() <libmproxy.controller.Channel.tell>` methods.
A :py:class:`~mitmproxy.controller.Channel` to communicate with the FlowMaster.
Provides :py:meth:`.ask() <mitmproxy.controller.Channel.ask>` and
:py:meth:`.tell() <mitmproxy.controller.Channel.tell>` methods.
config:
The :py:class:`proxy server's configuration <libmproxy.proxy.ProxyConfig>`
The :py:class:`proxy server's configuration <mitmproxy.proxy.ProxyConfig>`
"""
def __init__(self, client_conn, config, channel):

View File

@@ -68,14 +68,14 @@ class ConnectionHandler(object):
def __init__(self, client_conn, client_address, config, channel):
self.config = config
"""@type: libmproxy.proxy.config.ProxyConfig"""
"""@type: mitmproxy.proxy.config.ProxyConfig"""
self.client_conn = ClientConnection(
client_conn,
client_address,
None)
"""@type: libmproxy.proxy.connection.ClientConnection"""
"""@type: mitmproxy.proxy.connection.ClientConnection"""
self.channel = channel
"""@type: libmproxy.controller.Channel"""
"""@type: mitmproxy.controller.Channel"""
def _create_root_layer(self):
root_context = RootContext(

View File

@@ -9,7 +9,7 @@ import sys
here = os.path.abspath(os.path.dirname(__file__))
sys.path.append(os.path.join(here, "..", "netlib"))
from libmproxy import version
from mitmproxy import version
with open(os.path.join(here, 'README.rst'), encoding='utf-8') as f:
long_description = f.read()
@@ -45,9 +45,9 @@ setup(
include_package_data=True,
entry_points={
'console_scripts': [
'mitmproxy = libmproxy.main:mitmproxy',
'mitmdump = libmproxy.main:mitmdump',
'mitmweb = libmproxy.main:mitmweb'
'mitmproxy = mitmproxy.main:mitmproxy',
'mitmdump = mitmproxy.main:mitmdump',
'mitmweb = mitmproxy.main:mitmweb'
]
},
# https://packaging.python.org/en/latest/requirements/#install-requires

View File

@@ -1,8 +1,8 @@
var conf = {
src: "src/",
dist: "../libmproxy/web",
static: "../libmproxy/web/static",
dist: "../mitmproxy/web",
static: "../mitmproxy/web/static",
js: {
// Don't package these in the vendor distribution
vendor_excludes: [

View File

@@ -1,5 +1,5 @@
import time
from libmproxy.script import concurrent
from mitmproxy.script import concurrent
@concurrent

View File

@@ -1,4 +1,4 @@
from libmproxy.script import concurrent
from mitmproxy.script import concurrent
@concurrent

View File

@@ -1,5 +1,5 @@
import argparse
from libmproxy import cmdline
from mitmproxy import cmdline
from . import tutils

View File

@@ -1,8 +1,8 @@
import gc
import netlib.tutils
from libmproxy import console
from libmproxy.console import common
from mitmproxy import console
from mitmproxy.console import common
from . import tutils

View File

@@ -4,7 +4,7 @@ if os.name == "nt":
raise SkipTest("Skipped on Windows.")
import libmproxy.console.common as common
import mitmproxy.console.common as common
from . import tutils

View File

@@ -3,7 +3,7 @@ from unittest.case import SkipTest
if os.name == "nt":
raise SkipTest("Skipped on Windows.")
import libmproxy.console.help as help
import mitmproxy.console.help as help
class TestHelp:

View File

@@ -2,7 +2,7 @@ import os
from unittest.case import SkipTest
if os.name == "nt":
raise SkipTest("Skipped on Windows.")
import libmproxy.console.palettes as palettes
import mitmproxy.console.palettes as palettes
class TestPalette:

View File

@@ -1,6 +1,6 @@
import os
from os.path import normpath
from libmproxy.console import pathedit
from mitmproxy.console import pathedit
from . import tutils

View File

@@ -1,9 +1,9 @@
from libmproxy.exceptions import ContentViewException
from mitmproxy.exceptions import ContentViewException
from netlib.http import Headers
import netlib.utils
from netlib import encoding
import libmproxy.contentviews as cv
import mitmproxy.contentviews as cv
from . import tutils
try:

View File

@@ -1,5 +1,5 @@
import mock
from libmproxy import controller
from mitmproxy import controller
class TestMaster:

View File

@@ -1,4 +1,4 @@
import libmproxy.contentviews as cv
import mitmproxy.contentviews as cv
from netlib.http import Headers

View File

@@ -1,13 +1,13 @@
import os
from cStringIO import StringIO
from libmproxy.exceptions import ContentViewException
from libmproxy.models import HTTPResponse
from mitmproxy.exceptions import ContentViewException
from mitmproxy.models import HTTPResponse
import netlib.tutils
from netlib.http import CONTENT_MISSING
from libmproxy import dump, flow
from libmproxy.proxy import Log
from mitmproxy import dump, flow
from mitmproxy.proxy import Log
from . import tutils
import mock
@@ -49,7 +49,7 @@ def test_strfuncs():
m.echo_flow(flow)
@mock.patch("libmproxy.contentviews.get_content_view")
@mock.patch("mitmproxy.contentviews.get_content_view")
def test_contentview(get_content_view):
get_content_view.side_effect = ContentViewException(""), ("x", iter([]))

View File

@@ -1,11 +1,11 @@
import glob
from libmproxy import utils, script
from libmproxy.proxy import config
from mitmproxy import utils, script
from mitmproxy.proxy import config
from . import tservers
def test_load_scripts():
example_dir = utils.Data("libmproxy").path("../examples")
example_dir = utils.Data("mitmproxy").path("../examples")
scripts = glob.glob("%s/*.py" % example_dir)
tmaster = tservers.TestMaster(config.ProxyConfig())

View File

@@ -1,7 +1,7 @@
import cStringIO
from libmproxy import filt
from libmproxy.models import Error
from libmproxy.models import http
from mitmproxy import filt
from mitmproxy.models import Error
from mitmproxy.models import http
from netlib.http import Headers
from . import tutils

View File

@@ -9,16 +9,16 @@ import mock
import netlib.utils
from netlib import odict
from netlib.http import CONTENT_MISSING, Headers
from libmproxy import filt, controller, tnetstring, flow
from libmproxy.models import Error
from libmproxy.models import Flow
from libmproxy.models import HTTPFlow
from libmproxy.models import HTTPRequest
from libmproxy.models import HTTPResponse
from libmproxy.proxy.config import HostMatcher
from libmproxy.proxy import ProxyConfig
from libmproxy.proxy.server import DummyServer
from libmproxy.models.connections import ClientConnection
from mitmproxy import filt, controller, tnetstring, flow
from mitmproxy.models import Error
from mitmproxy.models import Flow
from mitmproxy.models import HTTPFlow
from mitmproxy.models import HTTPRequest
from mitmproxy.models import HTTPResponse
from mitmproxy.proxy.config import HostMatcher
from mitmproxy.proxy import ProxyConfig
from mitmproxy.proxy.server import DummyServer
from mitmproxy.models.connections import ClientConnection
from . import tutils

View File

@@ -1,7 +1,7 @@
from textwrap import dedent
import netlib.tutils
from libmproxy import flow_export
from mitmproxy import flow_export
from . import tutils
req_get = netlib.tutils.treq(

View File

@@ -1,4 +1,4 @@
from libmproxy.flow import FlowReader, FlowReadError
from mitmproxy.flow import FlowReader, FlowReadError
from . import tutils

View File

@@ -1,5 +1,5 @@
import sys
from libmproxy.platform import pf
from mitmproxy.platform import pf
from . import tutils

View File

@@ -6,8 +6,8 @@ import traceback
import os
import tempfile
from libmproxy.proxy.config import ProxyConfig
from libmproxy.cmdline import APP_HOST, APP_PORT
from mitmproxy.proxy.config import ProxyConfig
from mitmproxy.cmdline import APP_HOST, APP_PORT
import logging
logging.getLogger("hyper.packages.hpack.hpack").setLevel(logging.WARNING)

View File

@@ -2,11 +2,11 @@ import os
import mock
from OpenSSL import SSL
from libmproxy import cmdline
from libmproxy.proxy import ProxyConfig
from libmproxy.proxy.config import process_proxy_options
from libmproxy.models.connections import ServerConnection
from libmproxy.proxy.server import DummyServer, ProxyServer, ConnectionHandler
from mitmproxy import cmdline
from mitmproxy.proxy import ProxyConfig
from mitmproxy.proxy.config import process_proxy_options
from mitmproxy.models.connections import ServerConnection
from mitmproxy.proxy.server import DummyServer, ProxyServer, ConnectionHandler
from netlib.exceptions import TcpDisconnect
from libpathod import test
from netlib.http import http1
@@ -76,11 +76,11 @@ class TestProcessProxyOptions:
with tutils.tmpdir() as cadir:
self.assert_noerr("--cadir", cadir)
@mock.patch("libmproxy.platform.resolver", None)
@mock.patch("mitmproxy.platform.resolver", None)
def test_no_transparent(self):
self.assert_err("transparent mode not supported", "-T")
@mock.patch("libmproxy.platform.resolver")
@mock.patch("mitmproxy.platform.resolver")
def test_modes(self, _):
self.assert_noerr("-R", "http://localhost")
self.assert_err("expected one argument", "-R")

View File

@@ -1,7 +1,7 @@
import os
import time
import mock
from libmproxy import script, flow
from mitmproxy import script, flow
from . import tutils
@@ -68,7 +68,7 @@ def test_concurrent():
fm = flow.FlowMaster(None, s)
fm.load_script(tutils.test_data.path("scripts/concurrent_decorator.py"))
with mock.patch("libmproxy.controller.DummyReply.__call__") as m:
with mock.patch("mitmproxy.controller.DummyReply.__call__") as m:
f1, f2 = tutils.tflow(), tutils.tflow()
t_start = time.time()
fm.handle_request(f1)

View File

@@ -12,9 +12,9 @@ from netlib.http import authentication, CONTENT_MISSING, http1
from netlib.tutils import raises
from libpathod import pathoc, pathod
from libmproxy.proxy.config import HostMatcher
from libmproxy.protocol import Kill
from libmproxy.models import Error, HTTPResponse
from mitmproxy.proxy.config import HostMatcher
from mitmproxy.protocol import Kill
from mitmproxy.models import Error, HTTPResponse
from . import tutils, tservers

View File

@@ -1,5 +1,5 @@
import json
from libmproxy import utils
from mitmproxy import utils
from . import tutils
utils.CERT_SLEEP_TIME = 0

View File

@@ -5,7 +5,7 @@
# - Apache Bench "ab" binary
# - pip install click yappi
from libmproxy.main import mitmdump
from mitmproxy.main import mitmdump
from os import system
from threading import Thread
import time

View File

@@ -2,7 +2,7 @@ from pprint import pprint
import click
from libmproxy import tnetstring
from mitmproxy import tnetstring
def read_tnetstring(input):

View File

@@ -4,12 +4,12 @@ import tempfile
import flask
import mock
from libmproxy.proxy.config import ProxyConfig
from libmproxy.proxy.server import ProxyServer
from mitmproxy.proxy.config import ProxyConfig
from mitmproxy.proxy.server import ProxyServer
import libpathod.test
import libpathod.pathoc
from libmproxy import flow, controller
from libmproxy.cmdline import APP_HOST, APP_PORT
from mitmproxy import flow, controller
from mitmproxy.cmdline import APP_HOST, APP_PORT
testapp = flask.Flask(__name__)
@@ -192,7 +192,7 @@ class TransparentProxTest(ProxTestBase):
super(TransparentProxTest, cls).setup_class()
cls._resolver = mock.patch(
"libmproxy.platform.resolver",
"mitmproxy.platform.resolver",
new=lambda: cls.resolver(cls.server.port)
)
cls._resolver.start()

View File

@@ -9,8 +9,8 @@ from contextlib import contextmanager
from unittest.case import SkipTest
import netlib.tutils
from libmproxy import utils, controller
from libmproxy.models import (
from mitmproxy import utils, controller
from mitmproxy.models import (
ClientConnection, ServerConnection, Error, HTTPRequest, HTTPResponse, HTTPFlow
)
@@ -39,12 +39,12 @@ def skip_appveyor(fn):
def tflow(client_conn=True, server_conn=True, req=True, resp=None, err=None):
"""
@type client_conn: bool | None | libmproxy.proxy.connection.ClientConnection
@type server_conn: bool | None | libmproxy.proxy.connection.ServerConnection
@type req: bool | None | libmproxy.protocol.http.HTTPRequest
@type resp: bool | None | libmproxy.protocol.http.HTTPResponse
@type err: bool | None | libmproxy.protocol.primitives.Error
@return: bool | None | libmproxy.protocol.http.HTTPFlow
@type client_conn: bool | None | mitmproxy.proxy.connection.ClientConnection
@type server_conn: bool | None | mitmproxy.proxy.connection.ServerConnection
@type req: bool | None | mitmproxy.protocol.http.HTTPRequest
@type resp: bool | None | mitmproxy.protocol.http.HTTPResponse
@type err: bool | None | mitmproxy.protocol.primitives.Error
@return: bool | None | mitmproxy.protocol.http.HTTPFlow
"""
if client_conn is True:
client_conn = tclient_conn()
@@ -72,7 +72,7 @@ def tflow(client_conn=True, server_conn=True, req=True, resp=None, err=None):
def tclient_conn():
"""
@return: libmproxy.proxy.connection.ClientConnection
@return: mitmproxy.proxy.connection.ClientConnection
"""
c = ClientConnection.from_state(dict(
address=dict(address=("address", 22), use_ipv6=True),
@@ -88,7 +88,7 @@ def tclient_conn():
def tserver_conn():
"""
@return: libmproxy.proxy.connection.ServerConnection
@return: mitmproxy.proxy.connection.ServerConnection
"""
c = ServerConnection.from_state(dict(
address=dict(address=("address", 22), use_ipv6=True),
@@ -108,7 +108,7 @@ def tserver_conn():
def terr(content="error"):
"""
@return: libmproxy.protocol.primitives.Error
@return: mitmproxy.protocol.primitives.Error
"""
err = Error(content)
return err