Compare commits

...

14 Commits

Author SHA1 Message Date
Maximilian Hils
a0d76b33d1 0.18.3: warn about Python 2 usage 2016-12-27 01:49:46 +01:00
Maximilian Hils
058f1d42e3 Merge pull request #1735 from dwfreed/patch-1
Exempt localhost from upstream binding introduced in #879
2016-11-16 11:24:54 +01:00
Doug Freed
afb1a2a31d protocol/base: use upstream_bind_address option
Use the upstream_bind_address option, instead of listen_host, so the
localhost exception works.
2016-11-14 12:05:12 +00:00
Doug Freed
8be5853bc6 cmdline: add localhost exception to upstream bind
Add a localhost exception for the upstream bind address, so we don't
accidentally make upstream requests impossible.
2016-11-14 12:05:12 +00:00
Doug Freed
7d7b67c445 options: add upstream_bind_address
Add upstream_bind_address to the options object, so we can cache the
localhost exception.
2016-11-14 12:05:12 +00:00
Aldo Cortesi
9838cfb9d0 Merge pull request #1736 from dwfreed/travis-test
test/netlib/test_tcp: Update ciphers
2016-11-13 22:14:15 +13:00
Doug Freed
88a952a63e test/netlib/test_tcp: Update ciphers
Try updating ciphers to see if this fixes Travis builds.
2016-11-12 07:04:32 +00:00
Maximilian Hils
0a1ca53689 bump version to 0.18.2 2016-10-25 22:28:23 -07:00
Maximilian Hils
d0c27c76af fix the linter, knuth ftw! 2016-10-25 22:27:57 -07:00
Maximilian Hils
b72f3ee568 backport fix for #1620 2016-10-25 22:15:44 -07:00
Maximilian Hils
2fcc0458d1 backport fix for #1666 2016-10-25 22:09:58 -07:00
Maximilian Hils
fb1d2a8c89 constrain h2 version, refs #1671 2016-10-25 22:07:33 -07:00
Aldo Cortesi
6b524c9054 Merge pull request #1641 from cortesi/v0.18.x
console: correct handling of logs
2016-10-21 10:45:38 +13:00
Aldo Cortesi
ffe7eb94f1 console: correct handling of logs 2016-10-21 09:32:51 +13:00
11 changed files with 63 additions and 22 deletions

View File

@@ -19,7 +19,7 @@ class ClientPlayback:
def configure(self, options, updated):
if "client_replay" in updated:
if options.client_replay:
ctx.log.info(options.client_replay)
ctx.log.info("Client Replay: {}".format(options.client_replay))
try:
flows = flow.read_flows_from_paths(options.client_replay)
except exceptions.FlowReadException as e:

View File

@@ -208,6 +208,11 @@ def get_common_options(args):
if args.quiet:
args.verbose = 0
if args.addr in ("localhost", "127.0.0.1", "::1"):
upstream_bind_address = ""
else:
upstream_bind_address = args.addr
return dict(
app=args.app,
app_host=args.app_host,
@@ -251,6 +256,7 @@ def get_common_options(args):
ignore_hosts = args.ignore_hosts,
listen_host = args.addr,
listen_port = args.port,
upstream_bind_address = upstream_bind_address,
mode = mode,
no_upstream_cert = args.no_upstream_cert,
spoof_source_address = args.spoof_source_address,

View File

@@ -285,9 +285,6 @@ class ConsoleMaster(flow.FlowMaster):
self.logbuffer.pop(0)
self.logbuffer.set_focus(len(self.logbuffer) - 1)
def add_log(self, e, level):
signals.add_log(e, level)
def sig_call_in(self, sender, seconds, callback, args=()):
def cb(*_):
return callback(*args)
@@ -668,11 +665,10 @@ class ConsoleMaster(flow.FlowMaster):
)
def process_flow(self, f):
should_intercept = any(
[
self.state.intercept and flowfilter.match(self.state.intercept, f) and not f.request.is_replay,
f.intercepted,
]
should_intercept = (
self.state.intercept and flowfilter.match(self.state.intercept, f)
and not f.request.is_replay
and f.reply.state == "handled"
)
if should_intercept:
f.intercept(self)
@@ -703,9 +699,13 @@ class ConsoleMaster(flow.FlowMaster):
super(ConsoleMaster, self).tcp_message(f)
message = f.messages[-1]
direction = "->" if message.from_client else "<-"
self.add_log("{client} {direction} tcp {direction} {server}".format(
signals.add_log("{client} {direction} tcp {direction} {server}".format(
client=repr(f.client_conn.address),
server=repr(f.server_conn.address),
direction=direction,
), "info")
self.add_log(strutils.bytes_to_escaped_str(message.content), "debug")
signals.add_log(strutils.bytes_to_escaped_str(message.content), "debug")
@controller.handler
def log(self, evt):
signals.add_log(evt.msg, evt.level)

View File

@@ -14,6 +14,31 @@ from netlib import version_check
from netlib import debug
def py3():
print("""
Error: mitmproxy requires Python 3.5 or above
Starting with version 1.0 released in 12/2016, mitmproxy no longer supports Python 2.
To install the latest version of mitmproxy using pip on Python 3, run:
pip uninstall mitmproxy
pip3 install mitmproxy
You can also use our standalone binaries that come with their own Python interpreter:
http://docs.mitmproxy.org/en/stable/install.html
To get rid of this message and use the last version of mitmproxy that supports Python 2, run:
pip install "mitmproxy==0.18.2"
Apologies for the inconvenience!
""")
sys.exit(1)
def assert_utf8_env():
spec = ""
for i in ["LANG", "LC_CTYPE", "LC_ALL"]:
@@ -47,6 +72,7 @@ def process_options(parser, options, args):
def mitmproxy(args=None): # pragma: no cover
py3()
if os.name == "nt":
print("Error: mitmproxy's console interface is not supported on Windows. "
"You can run mitmdump or mitmweb instead.", file=sys.stderr)
@@ -83,6 +109,7 @@ def mitmproxy(args=None): # pragma: no cover
def mitmdump(args=None): # pragma: no cover
py3()
from . import dump
version_check.check_pyopenssl_version()
@@ -117,6 +144,7 @@ def mitmdump(args=None): # pragma: no cover
def mitmweb(args=None): # pragma: no cover
py3()
from . import web
version_check.check_pyopenssl_version()

View File

@@ -67,6 +67,7 @@ class Options(optmanager.OptManager):
ignore_hosts = (), # type: Sequence[str]
listen_host = "", # type: str
listen_port = LISTEN_PORT, # type: int
upstream_bind_address = "", # type: str
mode = "regular", # type: str
no_upstream_cert = False, # type: bool
rawtcp = False, # type: bool
@@ -127,6 +128,7 @@ class Options(optmanager.OptManager):
self.ignore_hosts = ignore_hosts
self.listen_host = listen_host
self.listen_port = listen_port
self.upstream_bind_address = upstream_bind_address
self.mode = mode
self.no_upstream_cert = no_upstream_cert
self.rawtcp = rawtcp

View File

@@ -121,7 +121,7 @@ class ServerConnectionMixin(object):
server_address, (self.ctx.client_conn.address.host, 0), True)
else:
self.server_conn = models.ServerConnection(
server_address, (self.config.options.listen_host, 0))
server_address, (self.config.options.upstream_bind_address, 0))
self.__check_self_connect()

View File

@@ -12,6 +12,7 @@ from mitmproxy import builtins
from mitmproxy import controller
from mitmproxy import exceptions
from mitmproxy import flow
from mitmproxy import flowfilter
from mitmproxy import options
from mitmproxy.web import app
from netlib.http import authentication
@@ -180,8 +181,12 @@ class WebMaster(flow.FlowMaster):
self.shutdown()
def _process_flow(self, f):
if self.state.intercept and self.state.intercept(
f) and not f.request.is_replay:
should_intercept = (
self.state.intercept and flowfilter.match(self.state.intercept, f)
and not f.request.is_replay
and f.reply.state == "handled"
)
if should_intercept:
f.intercept(self)
return f

View File

@@ -1,6 +1,6 @@
from __future__ import (absolute_import, print_function, division)
IVERSION = (0, 18, 1)
IVERSION = (0, 18, 3)
VERSION = ".".join(str(i) for i in IVERSION)
PATHOD = "pathod " + VERSION
MITMPROXY = "mitmproxy " + VERSION

View File

@@ -1,7 +1,7 @@
[flake8]
max-line-length = 140
max-complexity = 25
ignore = E251,C901
ignore = E251,C901,W503
exclude = mitmproxy/contrib/*,test/mitmproxy/data/*
builtins = file,open,basestring,xrange,unicode,long,cmp

View File

@@ -69,7 +69,7 @@ setup(
"cryptography>=1.3, <1.6",
"cssutils>=1.0.1, <1.1",
"Flask>=0.10.1, <0.12",
"h2>=2.4.1, <3",
"h2>=2.4.1, <2.5",
"html2text>=2016.1.8, <=2016.9.19",
"hyperframe>=4.0.1, <5",
"jsbeautifier>=1.6.3, <1.7",

View File

@@ -379,14 +379,14 @@ class TestSNI(tservers.ServerTestBase):
class TestServerCipherList(tservers.ServerTestBase):
handler = ClientCipherListHandler
ssl = dict(
cipher_list='RC4-SHA'
cipher_list='AES128-SHA'
)
def test_echo(self):
c = tcp.TCPClient(("127.0.0.1", self.port))
with c.connect():
c.convert_to_ssl(sni="foo.com")
assert c.rfile.readline() == b"['RC4-SHA']"
assert c.rfile.readline() == b"['AES128-SHA']"
class TestServerCurrentCipher(tservers.ServerTestBase):
@@ -399,14 +399,14 @@ class TestServerCurrentCipher(tservers.ServerTestBase):
self.wfile.flush()
ssl = dict(
cipher_list='RC4-SHA'
cipher_list='AES128-SHA'
)
def test_echo(self):
c = tcp.TCPClient(("127.0.0.1", self.port))
with c.connect():
c.convert_to_ssl(sni="foo.com")
assert b"RC4-SHA" in c.rfile.readline()
assert b"AES128-SHA" in c.rfile.readline()
class TestServerCipherListError(tservers.ServerTestBase):
@@ -424,7 +424,7 @@ class TestServerCipherListError(tservers.ServerTestBase):
class TestClientCipherListError(tservers.ServerTestBase):
handler = ClientCipherListHandler
ssl = dict(
cipher_list='RC4-SHA'
cipher_list='AES128-SHA'
)
def test_echo(self):