Merge pull request #950 from Kriechi/rename

Rename lib folders
This commit is contained in:
Aldo Cortesi 2016-02-17 10:35:41 +13:00
commit 887ecf8896
285 changed files with 341 additions and 346 deletions

View File

@ -17,7 +17,7 @@ install:
- "pip install --user -r requirements.txt"
- "python -c \"from OpenSSL import SSL; print(SSL.SSLeay_version(SSL.SSLEAY_VERSION))\""
test_script:
- "py.test -s --cov-config .coveragerc --timeout 30 ./test/"
- "py.test"
cache:
- C:\Users\appveyor\AppData\Local\pip\cache
deploy_script:

View File

@ -1,6 +1,6 @@
[run]
branch = True
include = libmproxy netlib libpathod
include = mitmproxy netlib pathod
omit = *contrib*, *tnetstring*, *platform*, *console*, *main.py
[report]

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,7 +1,7 @@
ignore-paths:
- mitmproxy/docs
- mitmproxy/examples
- mitmproxy/libmproxy/contrib
- mitmproxy/mitmproxy/contrib
- mitmproxy/web
max-line-length: 140
pylint:

View File

@ -44,7 +44,7 @@ before_script:
- "openssl version -a"
script:
- "py.test -s --cov-config .coveragerc --timeout 30 ./test/$SCOPE"
- "py.test ./test/$SCOPE"
after_success:
- coveralls
@ -72,4 +72,4 @@ cache:
directories:
- $HOME/.cache/pip
- $HOME/.pyenv
- $HOME/Library/Caches/pip
- $HOME/Library/Caches/pip

View File

@ -53,7 +53,7 @@ mitmproxy test suite:
.. code-block:: text
. venv/bin/activate # venv\Scripts\activate.bat on Windows
py.test --cov-config .coveragerc test
py.test
Note that the main executables for the project - ``mitmdump``, ``mitmproxy``,
``mitmweb``, ``pathod``, and ``pathoc`` - are all created within the virtualenv. After activating the
@ -76,7 +76,7 @@ requirements installed, and you can simply run the test suite:
.. code-block:: text
py.test --cov-config .coveragerc test
py.test
Please ensure that all patches are accompanied by matching changes in the test
suite. The project tries to maintain 100% test coverage.

View File

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

3
mitmproxy/bin/mitmdump Normal file
View File

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

3
mitmproxy/bin/mitmproxy Executable file
View File

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

4
mitmproxy/bin/mitmweb Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env python
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

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

View File

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

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

Some files were not shown because too many files have changed in this diff Show More