mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-22 15:37:45 +00:00
commit
00071238d2
@ -15,7 +15,7 @@ import os
|
||||
import sys
|
||||
|
||||
|
||||
class Wrapper(object):
|
||||
class Wrapper:
|
||||
def __init__(self, port, extra_arguments=None):
|
||||
self.port = port
|
||||
self.extra_arguments = extra_arguments
|
||||
|
@ -20,7 +20,6 @@ Example:
|
||||
|
||||
Authors: Maximilian Hils, Matthew Tuusberg
|
||||
"""
|
||||
from __future__ import absolute_import, print_function, division
|
||||
import collections
|
||||
import random
|
||||
|
||||
@ -38,7 +37,7 @@ class InterceptionResult(Enum):
|
||||
skipped = None
|
||||
|
||||
|
||||
class _TlsStrategy(object):
|
||||
class _TlsStrategy:
|
||||
"""
|
||||
Abstract base class for interception strategies.
|
||||
"""
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
from mitmproxy import exceptions
|
||||
import pprint
|
||||
|
||||
@ -7,7 +6,7 @@ def _get_name(itm):
|
||||
return getattr(itm, "name", itm.__class__.__name__.lower())
|
||||
|
||||
|
||||
class Addons(object):
|
||||
class Addons:
|
||||
def __init__(self, master):
|
||||
self.chain = []
|
||||
self.master = master
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
from mitmproxy.builtins import anticache
|
||||
from mitmproxy.builtins import anticomp
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
|
||||
class AntiCache:
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
|
||||
class AntiComp:
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import itertools
|
||||
|
||||
@ -20,7 +19,7 @@ def indent(n, text):
|
||||
return "\n".join(pad + i for i in l)
|
||||
|
||||
|
||||
class Dumper(object):
|
||||
class Dumper:
|
||||
def __init__(self):
|
||||
self.filter = None # type: flowfilter.TFilter
|
||||
self.flow_detail = None # type: int
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
import os.path
|
||||
|
||||
from mitmproxy import exceptions
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import contextlib
|
||||
import os
|
||||
@ -215,7 +214,7 @@ class Script:
|
||||
self.dead = True
|
||||
|
||||
|
||||
class ScriptLoader():
|
||||
class ScriptLoader:
|
||||
"""
|
||||
An addon that manages loading scripts from options.
|
||||
"""
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
import urllib
|
||||
import hashlib
|
||||
|
||||
@ -6,7 +5,7 @@ from netlib import strutils
|
||||
from mitmproxy import exceptions, flow, ctx
|
||||
|
||||
|
||||
class ServerPlayback(object):
|
||||
class ServerPlayback:
|
||||
def __init__(self):
|
||||
self.options = None
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
from mitmproxy import exceptions
|
||||
from mitmproxy import flowfilter
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import click
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import configargparse
|
||||
import os
|
||||
|
@ -1,6 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import os
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import urwid
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import urwid
|
||||
|
||||
@ -297,7 +296,7 @@ class FlowListBox(urwid.ListBox):
|
||||
|
||||
def __init__(self, master: "mitmproxy.console.master.ConsoleMaster"):
|
||||
self.master = master
|
||||
super(FlowListBox, self).__init__(FlowListWalker(master, master.state))
|
||||
super().__init__(FlowListWalker(master, master.state))
|
||||
|
||||
def get_method_raw(self, k):
|
||||
if k:
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import math
|
||||
import os
|
||||
@ -134,7 +133,7 @@ class FlowView(tabs.Tabs):
|
||||
|
||||
def __init__(self, master, state, flow, tab_offset):
|
||||
self.master, self.state, self.flow = master, state, flow
|
||||
super(FlowView, self).__init__(
|
||||
super().__init__(
|
||||
[
|
||||
(self.tab_request, self.view_request),
|
||||
(self.tab_response, self.view_response),
|
||||
@ -508,7 +507,7 @@ class FlowView(tabs.Tabs):
|
||||
elif self.tab_offset == TAB_RESP:
|
||||
conn = self.flow.response
|
||||
|
||||
key = super(self.__class__, self).keypress(size, key)
|
||||
key = super().keypress(size, key)
|
||||
|
||||
# Special case: Space moves over to the next flow.
|
||||
# We need to catch that before applying common.shortcuts()
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import abc
|
||||
import copy
|
||||
@ -35,7 +34,7 @@ class Cell(urwid.WidgetWrap):
|
||||
return True
|
||||
|
||||
|
||||
class Column(object, metaclass=abc.ABCMeta):
|
||||
class Column(metaclass=abc.ABCMeta):
|
||||
subeditor = None
|
||||
|
||||
def __init__(self, heading):
|
||||
@ -95,7 +94,7 @@ class GridRow(urwid.WidgetWrap):
|
||||
)
|
||||
if focused is not None:
|
||||
w.set_focus_column(focused)
|
||||
super(GridRow, self).__init__(w)
|
||||
super().__init__(w)
|
||||
|
||||
def keypress(self, s, k):
|
||||
if self.edit_col:
|
||||
@ -127,7 +126,7 @@ class GridWalker(urwid.ListWalker):
|
||||
|
||||
def _modified(self):
|
||||
self.editor.show_empty_msg()
|
||||
return super(GridWalker, self)._modified()
|
||||
return super()._modified()
|
||||
|
||||
def add_value(self, lst):
|
||||
self.lst.append(
|
||||
@ -245,7 +244,7 @@ class GridWalker(urwid.ListWalker):
|
||||
|
||||
class GridListBox(urwid.ListBox):
|
||||
def __init__(self, lw):
|
||||
super(GridListBox, self).__init__(lw)
|
||||
super().__init__(lw)
|
||||
|
||||
|
||||
FIRST_WIDTH_MAX = 40
|
||||
@ -301,7 +300,7 @@ class GridEditor(urwid.WidgetWrap):
|
||||
self.lb,
|
||||
header=urwid.Pile([title, h])
|
||||
)
|
||||
super(GridEditor, self).__init__(w)
|
||||
super().__init__(w)
|
||||
self.master.loop.widget.footer.update("")
|
||||
self.show_empty_msg()
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import os
|
||||
from typing import Callable, Optional
|
||||
@ -74,7 +73,7 @@ class Display(base.Cell):
|
||||
self.data = data
|
||||
escaped = strutils.bytes_to_escaped_str(data)
|
||||
w = urwid.Text(escaped, wrap="any")
|
||||
super(Display, self).__init__(w)
|
||||
super().__init__(w)
|
||||
|
||||
def get_data(self) -> bytes:
|
||||
return self.data
|
||||
@ -85,7 +84,7 @@ class Edit(base.Cell):
|
||||
data = strutils.bytes_to_escaped_str(data)
|
||||
w = urwid.Edit(edit_text=data, wrap="any", multiline=True)
|
||||
w = urwid.AttrWrap(w, "editfield")
|
||||
super(Edit, self).__init__(w)
|
||||
super().__init__(w)
|
||||
|
||||
def get_data(self) -> bytes:
|
||||
txt = self._w.get_text()[0].strip()
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
import urwid
|
||||
from mitmproxy.console.grideditor import base
|
||||
from mitmproxy.console import signals
|
||||
@ -7,7 +6,7 @@ from netlib.http import cookies
|
||||
|
||||
class Column(base.Column):
|
||||
def __init__(self, heading, subeditor):
|
||||
super(Column, self).__init__(heading)
|
||||
super().__init__(heading)
|
||||
self.subeditor = subeditor
|
||||
|
||||
def Edit(self, data):
|
||||
@ -45,7 +44,7 @@ class Display(base.Cell):
|
||||
def __init__(self, data):
|
||||
p = cookies._format_pairs(data, sep="\n")
|
||||
w = urwid.Text(p)
|
||||
super(Display, self).__init__(w)
|
||||
super().__init__(w)
|
||||
|
||||
def get_data(self):
|
||||
pass
|
||||
|
@ -4,7 +4,6 @@ Welcome to the encoding dance!
|
||||
In a nutshell, text columns are actually a proxy class for byte columns,
|
||||
which just encode/decodes contents.
|
||||
"""
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
from mitmproxy.console import signals
|
||||
from mitmproxy.console.grideditor import col_bytes
|
||||
@ -12,7 +11,7 @@ from mitmproxy.console.grideditor import col_bytes
|
||||
|
||||
class Column(col_bytes.Column):
|
||||
def __init__(self, heading, encoding="utf8", errors="surrogateescape"):
|
||||
super(Column, self).__init__(heading)
|
||||
super().__init__(heading)
|
||||
self.encoding_args = encoding, errors
|
||||
|
||||
def Display(self, data):
|
||||
@ -26,14 +25,15 @@ class Column(col_bytes.Column):
|
||||
|
||||
|
||||
# This is the same for both edit and display.
|
||||
class EncodingMixin(object):
|
||||
def __init__(self, data: str, encoding_args):
|
||||
class EncodingMixin:
|
||||
def __init__(self, data, encoding_args):
|
||||
# type: (str) -> TDisplay
|
||||
self.encoding_args = encoding_args
|
||||
data = data.encode(*self.encoding_args)
|
||||
super(EncodingMixin, self).__init__(data)
|
||||
super().__init__(data)
|
||||
|
||||
def get_data(self) -> str:
|
||||
data = super(EncodingMixin, self).get_data()
|
||||
data = super().get_data()
|
||||
try:
|
||||
return data.decode(*self.encoding_args)
|
||||
except ValueError:
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
import re
|
||||
import urwid
|
||||
from mitmproxy import exceptions
|
||||
@ -29,7 +28,7 @@ class HeaderEditor(base.GridEditor):
|
||||
]
|
||||
|
||||
def make_help(self):
|
||||
h = super(HeaderEditor, self).make_help()
|
||||
h = super().make_help()
|
||||
text = [
|
||||
urwid.Text([("text", "Special keys:\n")])
|
||||
]
|
||||
@ -106,7 +105,7 @@ class SetHeadersEditor(base.GridEditor):
|
||||
return False
|
||||
|
||||
def make_help(self):
|
||||
h = super(SetHeadersEditor, self).make_help()
|
||||
h = super().make_help()
|
||||
text = [
|
||||
urwid.Text([("text", "Special keys:\n")])
|
||||
]
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import platform
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import mailcap
|
||||
import mimetypes
|
||||
@ -65,19 +64,19 @@ class ConsoleState(flow.State):
|
||||
return d.get(key, default)
|
||||
|
||||
def add_flow(self, f):
|
||||
super(ConsoleState, self).add_flow(f)
|
||||
super().add_flow(f)
|
||||
signals.flowlist_change.send(self)
|
||||
self.update_focus()
|
||||
return f
|
||||
|
||||
def update_flow(self, f):
|
||||
super(ConsoleState, self).update_flow(f)
|
||||
super().update_flow(f)
|
||||
signals.flowlist_change.send(self)
|
||||
self.update_focus()
|
||||
return f
|
||||
|
||||
def set_view_filter(self, txt):
|
||||
ret = super(ConsoleState, self).set_view_filter(txt)
|
||||
ret = super().set_view_filter(txt)
|
||||
self.set_focus(self.focus)
|
||||
return ret
|
||||
|
||||
@ -121,7 +120,7 @@ class ConsoleState(flow.State):
|
||||
self.focus -= 1
|
||||
if self.focus < 0:
|
||||
self.focus = None
|
||||
ret = super(ConsoleState, self).delete_flow(f)
|
||||
ret = super().delete_flow(f)
|
||||
self.set_focus(self.focus)
|
||||
return ret
|
||||
|
||||
@ -185,7 +184,7 @@ class ConsoleState(flow.State):
|
||||
|
||||
def clear(self):
|
||||
marked_flows = [f for f in self.view if f.marked]
|
||||
super(ConsoleState, self).clear()
|
||||
super().clear()
|
||||
|
||||
for f in marked_flows:
|
||||
self.add_flow(f)
|
||||
@ -217,7 +216,7 @@ class Options(mitmproxy.options.Options):
|
||||
self.palette = palette
|
||||
self.palette_transparent = palette_transparent
|
||||
self.no_mouse = no_mouse
|
||||
super(Options, self).__init__(**kwargs)
|
||||
super().__init__(**kwargs)
|
||||
|
||||
|
||||
class ConsoleMaster(flow.FlowMaster):
|
||||
@ -679,22 +678,22 @@ class ConsoleMaster(flow.FlowMaster):
|
||||
# Handlers
|
||||
@controller.handler
|
||||
def error(self, f):
|
||||
super(ConsoleMaster, self).error(f)
|
||||
super().error(f)
|
||||
self.process_flow(f)
|
||||
|
||||
@controller.handler
|
||||
def request(self, f):
|
||||
super(ConsoleMaster, self).request(f)
|
||||
super().request(f)
|
||||
self.process_flow(f)
|
||||
|
||||
@controller.handler
|
||||
def response(self, f):
|
||||
super(ConsoleMaster, self).response(f)
|
||||
super().response(f)
|
||||
self.process_flow(f)
|
||||
|
||||
@controller.handler
|
||||
def tcp_message(self, f):
|
||||
super(ConsoleMaster, self).tcp_message(f)
|
||||
super().tcp_message(f)
|
||||
message = f.messages[-1]
|
||||
direction = "->" if message.from_client else "<-"
|
||||
self.add_log("{client} {direction} tcp {direction} {server}".format(
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import urwid
|
||||
|
||||
@ -144,7 +143,7 @@ class Options(urwid.WidgetWrap):
|
||||
self.lb,
|
||||
header = title
|
||||
)
|
||||
super(Options, self).__init__(w)
|
||||
super().__init__(w)
|
||||
|
||||
self.master.loop.widget.footer.update("")
|
||||
signals.update_settings.connect(self.sig_update_settings)
|
||||
@ -157,7 +156,7 @@ class Options(urwid.WidgetWrap):
|
||||
if key == "C":
|
||||
self.clearall()
|
||||
return None
|
||||
return super(self.__class__, self).keypress(size, key)
|
||||
return super().keypress(size, key)
|
||||
|
||||
def clearall(self):
|
||||
self.master.options.update(
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import urwid
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
#
|
||||
# http://urwid.org/manual/displayattributes.html
|
||||
#
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
|
||||
class Palette:
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import glob
|
||||
import os.path
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import urwid
|
||||
|
||||
@ -44,7 +43,7 @@ class Searchable(urwid.ListBox):
|
||||
self.set_focus(len(self.walker) - 1)
|
||||
self.walker._modified()
|
||||
else:
|
||||
return super(self.__class__, self).keypress(size, key)
|
||||
return super().keypress(size, key)
|
||||
|
||||
def set_search(self, text):
|
||||
self.state.last_search = text
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import urwid
|
||||
|
||||
@ -120,4 +119,4 @@ class Select(urwid.ListBox):
|
||||
self.keymap[key].activate()
|
||||
self.set_focus(self.options.index(self.keymap[key]))
|
||||
return None
|
||||
return super(self.__class__, self).keypress(size, key)
|
||||
return super().keypress(size, key)
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import blinker
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import os.path
|
||||
|
||||
@ -120,7 +119,7 @@ class StatusBar(urwid.WidgetWrap):
|
||||
self.master = master
|
||||
self.helptext = helptext
|
||||
self.ib = urwid.WidgetWrap(urwid.Text(""))
|
||||
super(StatusBar, self).__init__(urwid.Pile([self.ib, self.master.ab]))
|
||||
super().__init__(urwid.Pile([self.ib, self.master.ab]))
|
||||
signals.update_settings.connect(self.sig_update_settings)
|
||||
signals.flowlist_change.connect(self.sig_update_settings)
|
||||
master.options.changed.connect(self.sig_update_settings)
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import urwid
|
||||
|
||||
@ -25,7 +24,7 @@ class Tab(urwid.WidgetWrap):
|
||||
class Tabs(urwid.WidgetWrap):
|
||||
|
||||
def __init__(self, tabs, tab_offset=0):
|
||||
super(Tabs, self).__init__("")
|
||||
super().__init__("")
|
||||
self.tab_offset = tab_offset
|
||||
self.tabs = tabs
|
||||
self.show()
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import urwid
|
||||
|
||||
@ -23,7 +22,7 @@ class Window(urwid.Frame):
|
||||
|
||||
def mouse_event(self, *args, **kwargs):
|
||||
# args: (size, event, button, col, row)
|
||||
k = super(self.__class__, self).mouse_event(*args, **kwargs)
|
||||
k = super().mouse_event(*args, **kwargs)
|
||||
if not k:
|
||||
if args[1] == "mouse drag":
|
||||
signals.status_message.send(
|
||||
@ -83,7 +82,7 @@ class Window(urwid.Frame):
|
||||
)
|
||||
|
||||
def keypress(self, size, k):
|
||||
k = super(self.__class__, self).keypress(size, k)
|
||||
k = super().keypress(size, k)
|
||||
if k == "?":
|
||||
self.master.view_help(self.helpctx)
|
||||
elif k == "i":
|
||||
|
@ -12,7 +12,6 @@ use. For HTTP, the message headers are passed as the ``headers`` keyword argumen
|
||||
requests, the query parameters are passed as the ``query`` keyword argument.
|
||||
|
||||
"""
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import datetime
|
||||
import io
|
||||
@ -93,7 +92,7 @@ def format_text(text):
|
||||
yield [("text", line)]
|
||||
|
||||
|
||||
class View(object):
|
||||
class View:
|
||||
name = None
|
||||
prompt = ()
|
||||
content_types = []
|
||||
@ -309,7 +308,6 @@ if pyamf:
|
||||
data = input.readObject()
|
||||
self["data"] = data
|
||||
|
||||
|
||||
def pyamf_class_loader(s):
|
||||
for i in pyamf.CLASS_LOADERS:
|
||||
if i != pyamf_class_loader:
|
||||
@ -318,10 +316,8 @@ if pyamf:
|
||||
return v
|
||||
return DummyObject
|
||||
|
||||
|
||||
pyamf.register_class_loader(pyamf_class_loader)
|
||||
|
||||
|
||||
class ViewAMF(View):
|
||||
name = "AMF"
|
||||
prompt = ("amf", "f")
|
||||
|
@ -2,4 +2,3 @@
|
||||
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
|
||||
# for complete details.
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
@ -2,7 +2,6 @@
|
||||
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
|
||||
# for complete details.
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
from construct import (Array, Bytes, Struct, UBInt16, UBInt32, UBInt8, PascalString, Embed, TunnelAdapter, GreedyRange,
|
||||
Switch, OptionalGreedyRange, Optional)
|
||||
|
@ -2,7 +2,6 @@
|
||||
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
|
||||
# for complete details.
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
import construct
|
||||
|
||||
|
@ -49,4 +49,4 @@ class ASWBXMLCodePage:
|
||||
return None
|
||||
|
||||
def __repr__(self):
|
||||
return str(self.tokenLookup)
|
||||
return str(self.tokenLookup)
|
||||
|
@ -47,4 +47,4 @@ class GlobalTokens:
|
||||
EXT_1 = 0xC1
|
||||
EXT_2 = 0xC2
|
||||
OPAQUE = 0xC3
|
||||
LITERAL_AC = 0xC4
|
||||
LITERAL_AC = 0xC4
|
||||
|
@ -28,4 +28,4 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
'''
|
||||
class InvalidDataException(Exception):
|
||||
pass
|
||||
pass
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import functools
|
||||
import threading
|
||||
@ -41,13 +40,13 @@ Events = frozenset([
|
||||
])
|
||||
|
||||
|
||||
class LogEntry(object):
|
||||
class LogEntry:
|
||||
def __init__(self, msg, level):
|
||||
self.msg = msg
|
||||
self.level = level
|
||||
|
||||
|
||||
class Log(object):
|
||||
class Log:
|
||||
"""
|
||||
The central logger, exposed to scripts as mitmproxy.ctx.log.
|
||||
"""
|
||||
@ -82,7 +81,7 @@ class Log(object):
|
||||
self.master.add_log(text, level)
|
||||
|
||||
|
||||
class Master(object):
|
||||
class Master:
|
||||
"""
|
||||
The master handles mitmproxy's main event loop.
|
||||
"""
|
||||
@ -177,7 +176,7 @@ class ServerThread(basethread.BaseThread):
|
||||
def __init__(self, server):
|
||||
self.server = server
|
||||
address = getattr(self.server, "address", None)
|
||||
super(ServerThread, self).__init__(
|
||||
super().__init__(
|
||||
"ServerThread ({})".format(repr(address))
|
||||
)
|
||||
|
||||
@ -185,7 +184,7 @@ class ServerThread(basethread.BaseThread):
|
||||
self.server.serve_forever()
|
||||
|
||||
|
||||
class Channel(object):
|
||||
class Channel:
|
||||
"""
|
||||
The only way for the proxy server to communicate with the master
|
||||
is to use the channel it has been given.
|
||||
@ -272,7 +271,7 @@ def handler(f):
|
||||
NO_REPLY = object() # special object we can distinguish from a valid "None" reply.
|
||||
|
||||
|
||||
class Reply(object):
|
||||
class Reply:
|
||||
"""
|
||||
Messages sent through a channel are decorated with a "reply" attribute.
|
||||
This object is used to respond to the message through the return
|
||||
@ -362,7 +361,7 @@ class DummyReply(Reply):
|
||||
and during testing.
|
||||
"""
|
||||
def __init__(self):
|
||||
super(DummyReply, self).__init__(None)
|
||||
super().__init__(None)
|
||||
self._should_reset = False
|
||||
|
||||
def mark_reset(self):
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import typing
|
||||
from typing import Optional
|
||||
@ -29,7 +28,7 @@ class Options(options.Options):
|
||||
self.flow_detail = flow_detail
|
||||
self.keepserving = keepserving
|
||||
self.tfile = tfile
|
||||
super(Options, self).__init__(**kwargs)
|
||||
super().__init__(**kwargs)
|
||||
|
||||
|
||||
class DumpMaster(flow.FlowMaster):
|
||||
@ -86,4 +85,4 @@ class DumpMaster(flow.FlowMaster):
|
||||
if self.options.rfile and not self.options.keepserving:
|
||||
self.addons.done()
|
||||
return
|
||||
super(DumpMaster, self).run()
|
||||
super().run()
|
||||
|
@ -5,7 +5,6 @@ Every Exception mitmproxy raises shall be a subclass of ProxyException.
|
||||
|
||||
See also: http://lucumr.pocoo.org/2014/10/16/on-error-handling/
|
||||
"""
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
|
||||
class ProxyException(Exception):
|
||||
@ -15,7 +14,7 @@ class ProxyException(Exception):
|
||||
"""
|
||||
|
||||
def __init__(self, message=None):
|
||||
super(ProxyException, self).__init__(message)
|
||||
super().__init__(message)
|
||||
|
||||
|
||||
class Kill(ProxyException):
|
||||
@ -41,7 +40,7 @@ class TlsProtocolException(ProtocolException):
|
||||
class ClientHandshakeException(TlsProtocolException):
|
||||
|
||||
def __init__(self, message, server):
|
||||
super(ClientHandshakeException, self).__init__(message)
|
||||
super().__init__(message)
|
||||
self.server = server
|
||||
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
from mitmproxy.flow import export, modules
|
||||
from mitmproxy.flow.io import FlowWriter, FilteredFlowWriter, FlowReader, read_flows_from_paths
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import json
|
||||
import re
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import os
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
"""
|
||||
This module handles the import of mitmproxy flows generated by old versions.
|
||||
"""
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
from typing import Any
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import os
|
||||
import sys
|
||||
@ -51,7 +50,7 @@ class FlowMaster(controller.Master):
|
||||
return self.servers[0]
|
||||
|
||||
def __init__(self, options, server, state):
|
||||
super(FlowMaster, self).__init__(options)
|
||||
super().__init__(options)
|
||||
if server:
|
||||
self.add_server(server)
|
||||
self.state = state
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
from netlib import wsgi
|
||||
from netlib import version
|
||||
@ -32,7 +31,7 @@ class AppRegistry:
|
||||
return self.apps.get((host, request.port), None)
|
||||
|
||||
|
||||
class StreamLargeBodies(object):
|
||||
class StreamLargeBodies:
|
||||
def __init__(self, max_size):
|
||||
self.max_size = max_size
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
from abc import abstractmethod, ABCMeta
|
||||
|
||||
@ -49,7 +48,7 @@ def _pos(*args):
|
||||
|
||||
class FlowView(FlowList):
|
||||
def __init__(self, store, flt=None):
|
||||
super(FlowView, self).__init__()
|
||||
super().__init__()
|
||||
if not flt:
|
||||
flt = _pos
|
||||
self._build(store, flt)
|
||||
@ -90,7 +89,7 @@ class FlowStore(FlowList):
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super(FlowStore, self).__init__()
|
||||
super().__init__()
|
||||
self._set = set() # Used for O(1) lookups
|
||||
self.views = []
|
||||
self._recalculate_views()
|
||||
@ -177,7 +176,7 @@ class FlowStore(FlowList):
|
||||
f.kill(master)
|
||||
|
||||
|
||||
class State(object):
|
||||
class State:
|
||||
def __init__(self):
|
||||
self.flows = FlowStore()
|
||||
self.view = FlowView(self.flows, None)
|
||||
|
@ -31,7 +31,6 @@
|
||||
~c CODE Response code.
|
||||
rex Equivalent to ~u rex
|
||||
"""
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import re
|
||||
import sys
|
||||
@ -58,7 +57,7 @@ def only(*types):
|
||||
return decorator
|
||||
|
||||
|
||||
class _Token(object):
|
||||
class _Token:
|
||||
|
||||
def dump(self, indent=0, fp=sys.stdout):
|
||||
print("{spacing}{name}{expr}".format(
|
||||
@ -373,7 +372,7 @@ class FAnd(_Token):
|
||||
self.lst = lst
|
||||
|
||||
def dump(self, indent=0, fp=sys.stdout):
|
||||
super(FAnd, self).dump(indent, fp)
|
||||
super().dump(indent, fp)
|
||||
for i in self.lst:
|
||||
i.dump(indent + 1, fp)
|
||||
|
||||
@ -387,7 +386,7 @@ class FOr(_Token):
|
||||
self.lst = lst
|
||||
|
||||
def dump(self, indent=0, fp=sys.stdout):
|
||||
super(FOr, self).dump(indent, fp)
|
||||
super().dump(indent, fp)
|
||||
for i in self.lst:
|
||||
i.dump(indent + 1, fp)
|
||||
|
||||
@ -401,7 +400,7 @@ class FNot(_Token):
|
||||
self.itm = itm[0]
|
||||
|
||||
def dump(self, indent=0, fp=sys.stdout):
|
||||
super(FNot, self).dump(indent, fp)
|
||||
super().dump(indent, fp)
|
||||
self.itm.dump(indent + 1, fp)
|
||||
|
||||
def __call__(self, f):
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import os
|
||||
import signal
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
from netlib.http import decoded
|
||||
from .connections import ClientConnection, ServerConnection
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
import time
|
||||
|
||||
import copy
|
||||
@ -27,7 +26,7 @@ class ClientConnection(tcp.BaseHandler, stateobject.StateObject):
|
||||
# Eventually, this object is restored from state. We don't have a
|
||||
# connection then.
|
||||
if client_connection:
|
||||
super(ClientConnection, self).__init__(client_connection, address, server)
|
||||
super().__init__(client_connection, address, server)
|
||||
else:
|
||||
self.connection = None
|
||||
self.server = None
|
||||
@ -91,11 +90,11 @@ class ClientConnection(tcp.BaseHandler, stateobject.StateObject):
|
||||
))
|
||||
|
||||
def convert_to_ssl(self, *args, **kwargs):
|
||||
super(ClientConnection, self).convert_to_ssl(*args, **kwargs)
|
||||
super().convert_to_ssl(*args, **kwargs)
|
||||
self.timestamp_ssl_setup = time.time()
|
||||
|
||||
def finish(self):
|
||||
super(ClientConnection, self).finish()
|
||||
super().finish()
|
||||
self.timestamp_end = time.time()
|
||||
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import time
|
||||
import copy
|
||||
@ -97,7 +96,7 @@ class Flow(stateobject.StateObject):
|
||||
)
|
||||
|
||||
def get_state(self):
|
||||
d = super(Flow, self).get_state()
|
||||
d = super().get_state()
|
||||
d.update(version=version.IVERSION)
|
||||
if self._backup and self._backup != d:
|
||||
d.update(backup=self._backup)
|
||||
@ -107,7 +106,7 @@ class Flow(stateobject.StateObject):
|
||||
state.pop("version")
|
||||
if "backup" in state:
|
||||
self._backup = state.pop("backup")
|
||||
super(Flow, self).set_state(state)
|
||||
super().set_state(state)
|
||||
|
||||
@classmethod
|
||||
def from_state(cls, state):
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import cgi
|
||||
|
||||
@ -57,7 +56,7 @@ class HTTPRequest(http.Request):
|
||||
self.is_replay = is_replay
|
||||
|
||||
def get_state(self):
|
||||
state = super(HTTPRequest, self).get_state()
|
||||
state = super().get_state()
|
||||
state.update(
|
||||
stickycookie=self.stickycookie,
|
||||
stickyauth=self.stickyauth,
|
||||
@ -69,7 +68,7 @@ class HTTPRequest(http.Request):
|
||||
self.stickycookie = state.pop("stickycookie")
|
||||
self.stickyauth = state.pop("stickyauth")
|
||||
self.is_replay = state.pop("is_replay")
|
||||
super(HTTPRequest, self).set_state(state)
|
||||
super().set_state(state)
|
||||
|
||||
@classmethod
|
||||
def wrap(self, request):
|
||||
@ -154,7 +153,7 @@ class HTTPFlow(flow.Flow):
|
||||
"""
|
||||
|
||||
def __init__(self, client_conn, server_conn, live=None):
|
||||
super(HTTPFlow, self).__init__("http", client_conn, server_conn, live)
|
||||
super().__init__("http", client_conn, server_conn, live)
|
||||
|
||||
self.request = None
|
||||
""" :py:class:`HTTPRequest` object """
|
||||
@ -189,7 +188,7 @@ class HTTPFlow(flow.Flow):
|
||||
return s.format(flow=self)
|
||||
|
||||
def copy(self):
|
||||
f = super(HTTPFlow, self).copy()
|
||||
f = super().copy()
|
||||
if self.request:
|
||||
f.request = self.request.copy()
|
||||
if self.response:
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import time
|
||||
|
||||
@ -43,7 +42,7 @@ class TCPFlow(Flow):
|
||||
"""
|
||||
|
||||
def __init__(self, client_conn, server_conn, live=None):
|
||||
super(TCPFlow, self).__init__("tcp", client_conn, server_conn, live)
|
||||
super().__init__("tcp", client_conn, server_conn, live)
|
||||
self.messages = [] # type: List[TCPMessage]
|
||||
|
||||
_stateobject_attributes = Flow._stateobject_attributes.copy()
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import os
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
from typing import Tuple, Optional, Sequence
|
||||
|
||||
@ -141,4 +140,4 @@ class Options(optmanager.OptManager):
|
||||
self.ssl_verify_upstream_trusted_cadir = ssl_verify_upstream_trusted_cadir
|
||||
self.ssl_verify_upstream_trusted_ca = ssl_verify_upstream_trusted_ca
|
||||
self.tcp_hosts = tcp_hosts
|
||||
super(Options, self).__init__()
|
||||
super().__init__()
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import contextlib
|
||||
import blinker
|
||||
@ -11,7 +10,7 @@ from mitmproxy import exceptions
|
||||
"""
|
||||
|
||||
|
||||
class OptManager(object):
|
||||
class OptManager:
|
||||
"""
|
||||
.changed is a blinker Signal that triggers whenever options are
|
||||
updated. If any handler in the chain raises an exceptions.OptionsError
|
||||
@ -25,7 +24,7 @@ class OptManager(object):
|
||||
# Initialize instance._opts before __init__ is called.
|
||||
# This allows us to call super().__init__() last, which then sets
|
||||
# ._initialized = True as the final operation.
|
||||
instance = super(OptManager, cls).__new__(cls)
|
||||
instance = super().__new__(cls)
|
||||
instance.__dict__["_opts"] = {}
|
||||
return instance
|
||||
|
||||
|
@ -5,7 +5,7 @@ import struct
|
||||
SO_ORIGINAL_DST = 80
|
||||
|
||||
|
||||
class Resolver(object):
|
||||
class Resolver:
|
||||
|
||||
def original_addr(self, csock):
|
||||
odestdata = csock.getsockopt(socket.SOL_IP, SO_ORIGINAL_DST, 16)
|
||||
|
@ -15,7 +15,7 @@ from . import pf
|
||||
"""
|
||||
|
||||
|
||||
class Resolver(object):
|
||||
class Resolver:
|
||||
STATECMD = ("sudo", "-n", "/sbin/pfctl", "-s", "state")
|
||||
|
||||
def original_addr(self, csock):
|
||||
|
@ -16,7 +16,7 @@ import socketserver
|
||||
PROXY_API_PORT = 8085
|
||||
|
||||
|
||||
class Resolver(object):
|
||||
class Resolver:
|
||||
|
||||
def __init__(self):
|
||||
TransparentProxy.setup()
|
||||
@ -111,7 +111,7 @@ def MIB_TCPTABLE2(size):
|
||||
return _MIB_TCPTABLE2()
|
||||
|
||||
|
||||
class TransparentProxy(object):
|
||||
class TransparentProxy:
|
||||
|
||||
"""
|
||||
Transparent Windows Proxy for mitmproxy based on WinDivert/PyDivert.
|
||||
|
@ -28,7 +28,6 @@ should be established as late as possible; this makes server replay without any
|
||||
outgoing connections possible.
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
from .base import Layer, ServerConnectionMixin
|
||||
from .http import UpstreamConnectLayer
|
||||
|
@ -1,18 +1,17 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import netlib.exceptions
|
||||
from mitmproxy import exceptions
|
||||
from mitmproxy import models
|
||||
|
||||
|
||||
class _LayerCodeCompletion(object):
|
||||
class _LayerCodeCompletion:
|
||||
|
||||
"""
|
||||
Dummy class that provides type hinting in PyCharm, which simplifies development a lot.
|
||||
"""
|
||||
|
||||
def __init__(self, **mixin_args): # pragma: no cover
|
||||
super(_LayerCodeCompletion, self).__init__(**mixin_args)
|
||||
super().__init__(**mixin_args)
|
||||
if True:
|
||||
return
|
||||
self.config = None
|
||||
@ -58,7 +57,7 @@ class Layer(_LayerCodeCompletion):
|
||||
|
||||
:type: :py:class:`Layer`
|
||||
"""
|
||||
super(Layer, self).__init__(**mixin_args)
|
||||
super().__init__(**mixin_args)
|
||||
|
||||
def __call__(self):
|
||||
"""Logic of the layer.
|
||||
@ -88,7 +87,7 @@ class Layer(_LayerCodeCompletion):
|
||||
return type(self).__name__
|
||||
|
||||
|
||||
class ServerConnectionMixin(object):
|
||||
class ServerConnectionMixin:
|
||||
|
||||
"""
|
||||
Mixin that provides a layer with the capabilities to manage a server connection.
|
||||
@ -109,7 +108,7 @@ class ServerConnectionMixin(object):
|
||||
"""
|
||||
|
||||
def __init__(self, server_address=None):
|
||||
super(ServerConnectionMixin, self).__init__()
|
||||
super().__init__()
|
||||
|
||||
self.server_conn = None
|
||||
if self.config.options.spoof_source_address:
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import h2.exceptions
|
||||
import netlib.exceptions
|
||||
@ -61,7 +60,7 @@ class _HttpTransmissionLayer(base.Layer):
|
||||
raise NotImplementedError()
|
||||
|
||||
|
||||
class ConnectServerConnection(object):
|
||||
class ConnectServerConnection:
|
||||
|
||||
"""
|
||||
"Fake" ServerConnection to represent state after a CONNECT request to an upstream proxy.
|
||||
@ -85,7 +84,7 @@ class ConnectServerConnection(object):
|
||||
class UpstreamConnectLayer(base.Layer):
|
||||
|
||||
def __init__(self, ctx, connect_request):
|
||||
super(UpstreamConnectLayer, self).__init__(ctx)
|
||||
super().__init__(ctx)
|
||||
self.connect_request = connect_request
|
||||
self.server_conn = ConnectServerConnection(
|
||||
(connect_request.host, connect_request.port),
|
||||
@ -125,7 +124,7 @@ class UpstreamConnectLayer(base.Layer):
|
||||
class HttpLayer(base.Layer):
|
||||
|
||||
def __init__(self, ctx, mode):
|
||||
super(HttpLayer, self).__init__(ctx)
|
||||
super().__init__(ctx)
|
||||
self.mode = mode
|
||||
|
||||
self.__initial_server_conn = None
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
from mitmproxy import models
|
||||
from mitmproxy.protocol import http
|
||||
@ -8,7 +7,7 @@ from netlib.http import http1
|
||||
class Http1Layer(http._HttpTransmissionLayer):
|
||||
|
||||
def __init__(self, ctx, mode):
|
||||
super(Http1Layer, self).__init__(ctx)
|
||||
super().__init__(ctx)
|
||||
self.mode = mode
|
||||
|
||||
def read_request_headers(self):
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import threading
|
||||
import time
|
||||
@ -24,7 +23,7 @@ from netlib.http import http2
|
||||
class SafeH2Connection(connection.H2Connection):
|
||||
|
||||
def __init__(self, conn, *args, **kwargs):
|
||||
super(SafeH2Connection, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
self.conn = conn
|
||||
self.lock = threading.RLock()
|
||||
|
||||
@ -89,7 +88,7 @@ class SafeH2Connection(connection.H2Connection):
|
||||
class Http2Layer(base.Layer):
|
||||
|
||||
def __init__(self, ctx, mode):
|
||||
super(Http2Layer, self).__init__(ctx)
|
||||
super().__init__(ctx)
|
||||
self.mode = mode
|
||||
self.streams = dict()
|
||||
self.server_to_client_stream_ids = dict([(0, 0)])
|
||||
@ -363,7 +362,7 @@ def detect_zombie_stream(func):
|
||||
class Http2SingleStreamLayer(http._HttpTransmissionLayer, basethread.BaseThread):
|
||||
|
||||
def __init__(self, ctx, h2_connection, stream_id, request_headers):
|
||||
super(Http2SingleStreamLayer, self).__init__(
|
||||
super().__init__(
|
||||
ctx, name="Http2SingleStreamLayer-{}".format(stream_id)
|
||||
)
|
||||
self.h2_connection = h2_connection
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import traceback
|
||||
|
||||
@ -27,7 +26,7 @@ class RequestReplayThread(basethread.BaseThread):
|
||||
self.channel = controller.Channel(event_queue, should_exit)
|
||||
else:
|
||||
self.channel = None
|
||||
super(RequestReplayThread, self).__init__(
|
||||
super().__init__(
|
||||
"RequestReplay (%s)" % flow.request.url
|
||||
)
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import socket
|
||||
|
||||
@ -16,7 +15,7 @@ class RawTCPLayer(base.Layer):
|
||||
|
||||
def __init__(self, ctx, ignore=False):
|
||||
self.ignore = ignore
|
||||
super(RawTCPLayer, self).__init__(ctx)
|
||||
super().__init__(ctx)
|
||||
|
||||
def __call__(self):
|
||||
self.connect()
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import struct
|
||||
from typing import Optional # noqa
|
||||
@ -248,7 +247,7 @@ def get_client_hello(client_conn):
|
||||
return client_hello
|
||||
|
||||
|
||||
class TlsClientHello(object):
|
||||
class TlsClientHello:
|
||||
|
||||
def __init__(self, raw_client_hello):
|
||||
self._client_hello = _constructs.ClientHello.parse(raw_client_hello)
|
||||
@ -318,7 +317,7 @@ class TlsLayer(base.Layer):
|
||||
"""
|
||||
|
||||
def __init__(self, ctx, client_tls, server_tls, custom_server_sni = None):
|
||||
super(TlsLayer, self).__init__(ctx)
|
||||
super().__init__(ctx)
|
||||
self._client_tls = client_tls
|
||||
self._server_tls = server_tls
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import netlib.exceptions
|
||||
import socket
|
||||
@ -35,7 +34,7 @@ class WebSocketsLayer(base.Layer):
|
||||
"""
|
||||
|
||||
def __init__(self, ctx, flow):
|
||||
super(WebSocketsLayer, self).__init__(ctx)
|
||||
super().__init__(ctx)
|
||||
self._flow = flow
|
||||
|
||||
self.client_key = websockets.get_client_key(self._flow.request.headers)
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
from .config import ProxyConfig
|
||||
from .root_context import RootContext
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import base64
|
||||
import collections
|
||||
@ -20,7 +19,7 @@ from netlib.http import url
|
||||
CONF_BASENAME = "mitmproxy"
|
||||
|
||||
|
||||
class HostMatcher(object):
|
||||
class HostMatcher:
|
||||
|
||||
def __init__(self, patterns=tuple()):
|
||||
self.patterns = list(patterns)
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
from .http_proxy import HttpProxy, HttpUpstreamProxy
|
||||
from .reverse_proxy import ReverseProxy
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
from mitmproxy import protocol
|
||||
|
||||
@ -17,7 +16,7 @@ class HttpProxy(protocol.Layer, protocol.ServerConnectionMixin):
|
||||
class HttpUpstreamProxy(protocol.Layer, protocol.ServerConnectionMixin):
|
||||
|
||||
def __init__(self, ctx, server_address):
|
||||
super(HttpUpstreamProxy, self).__init__(ctx, server_address=server_address)
|
||||
super().__init__(ctx, server_address=server_address)
|
||||
|
||||
def __call__(self):
|
||||
layer = self.ctx.next_layer(self)
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
from mitmproxy import protocol
|
||||
|
||||
@ -6,7 +5,7 @@ from mitmproxy import protocol
|
||||
class ReverseProxy(protocol.Layer, protocol.ServerConnectionMixin):
|
||||
|
||||
def __init__(self, ctx, server_address, server_tls):
|
||||
super(ReverseProxy, self).__init__(ctx, server_address=server_address)
|
||||
super().__init__(ctx, server_address=server_address)
|
||||
self.server_tls = server_tls
|
||||
|
||||
def __call__(self):
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import netlib.exceptions
|
||||
from mitmproxy import exceptions
|
||||
@ -10,7 +9,7 @@ from netlib import tcp
|
||||
class Socks5Proxy(protocol.Layer, protocol.ServerConnectionMixin):
|
||||
|
||||
def __init__(self, ctx):
|
||||
super(Socks5Proxy, self).__init__(ctx)
|
||||
super().__init__(ctx)
|
||||
|
||||
def __call__(self):
|
||||
try:
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
from mitmproxy import exceptions
|
||||
from mitmproxy import platform
|
||||
@ -8,7 +7,7 @@ from mitmproxy import protocol
|
||||
class TransparentProxy(protocol.Layer, protocol.ServerConnectionMixin):
|
||||
|
||||
def __init__(self, ctx):
|
||||
super(TransparentProxy, self).__init__(ctx)
|
||||
super().__init__(ctx)
|
||||
self.resolver = platform.resolver()
|
||||
|
||||
def __call__(self):
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import netlib.exceptions
|
||||
from mitmproxy import controller
|
||||
@ -7,7 +6,7 @@ from mitmproxy import protocol
|
||||
from mitmproxy.proxy import modes
|
||||
|
||||
|
||||
class RootContext(object):
|
||||
class RootContext:
|
||||
|
||||
"""
|
||||
The outermost context provided to the root layer.
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import socket
|
||||
import sys
|
||||
@ -40,7 +39,7 @@ class ProxyServer(tcp.TCPServer):
|
||||
"""
|
||||
self.config = config
|
||||
try:
|
||||
super(ProxyServer, self).__init__(
|
||||
super().__init__(
|
||||
(config.options.listen_host, config.options.listen_port)
|
||||
)
|
||||
except socket.error as e:
|
||||
@ -62,7 +61,7 @@ class ProxyServer(tcp.TCPServer):
|
||||
h.handle()
|
||||
|
||||
|
||||
class ConnectionHandler(object):
|
||||
class ConnectionHandler:
|
||||
|
||||
def __init__(self, client_conn, client_address, config, channel):
|
||||
self.config = config
|
||||
|
@ -2,7 +2,6 @@
|
||||
This module provides a @concurrent decorator primitive to
|
||||
offload computations from mitmproxy's main master thread.
|
||||
"""
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
from mitmproxy import controller
|
||||
from netlib import basethread
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
from typing import Any
|
||||
from typing import List
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import netlib.utils
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import base64
|
||||
import json
|
||||
@ -73,7 +72,7 @@ class APIError(tornado.web.HTTPError):
|
||||
pass
|
||||
|
||||
|
||||
class BasicAuth(object):
|
||||
class BasicAuth:
|
||||
|
||||
def set_auth_headers(self):
|
||||
self.set_status(401)
|
||||
@ -98,7 +97,7 @@ class BasicAuth(object):
|
||||
class RequestHandler(BasicAuth, tornado.web.RequestHandler):
|
||||
|
||||
def set_default_headers(self):
|
||||
super(RequestHandler, self).set_default_headers()
|
||||
super().set_default_headers()
|
||||
self.set_header("Server", version.MITMPROXY)
|
||||
self.set_header("X-Frame-Options", "DENY")
|
||||
self.add_header("X-XSS-Protection", "1; mode=block")
|
||||
@ -137,7 +136,7 @@ class RequestHandler(BasicAuth, tornado.web.RequestHandler):
|
||||
if "exc_info" in kwargs and isinstance(kwargs["exc_info"][1], APIError):
|
||||
self.finish(kwargs["exc_info"][1].log_message)
|
||||
else:
|
||||
super(RequestHandler, self).write_error(status_code, **kwargs)
|
||||
super().write_error(status_code, **kwargs)
|
||||
|
||||
|
||||
class IndexHandler(RequestHandler):
|
||||
@ -456,4 +455,4 @@ class Application(tornado.web.Application):
|
||||
autoreload=False,
|
||||
wauthenticator=wauthenticator,
|
||||
)
|
||||
super(Application, self).__init__(handlers, **settings)
|
||||
super().__init__(handlers, **settings)
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import sys
|
||||
import collections
|
||||
@ -24,10 +23,10 @@ class Stop(Exception):
|
||||
class WebFlowView(flow.FlowView):
|
||||
|
||||
def __init__(self, store):
|
||||
super(WebFlowView, self).__init__(store, None)
|
||||
super().__init__(store, None)
|
||||
|
||||
def _add(self, f):
|
||||
super(WebFlowView, self)._add(f)
|
||||
super()._add(f)
|
||||
app.ClientConnection.broadcast(
|
||||
type="UPDATE_FLOWS",
|
||||
cmd="add",
|
||||
@ -35,7 +34,7 @@ class WebFlowView(flow.FlowView):
|
||||
)
|
||||
|
||||
def _update(self, f):
|
||||
super(WebFlowView, self)._update(f)
|
||||
super()._update(f)
|
||||
app.ClientConnection.broadcast(
|
||||
type="UPDATE_FLOWS",
|
||||
cmd="update",
|
||||
@ -43,7 +42,7 @@ class WebFlowView(flow.FlowView):
|
||||
)
|
||||
|
||||
def _remove(self, f):
|
||||
super(WebFlowView, self)._remove(f)
|
||||
super()._remove(f)
|
||||
app.ClientConnection.broadcast(
|
||||
type="UPDATE_FLOWS",
|
||||
cmd="remove",
|
||||
@ -51,7 +50,7 @@ class WebFlowView(flow.FlowView):
|
||||
)
|
||||
|
||||
def _recalculate(self, flows):
|
||||
super(WebFlowView, self)._recalculate(flows)
|
||||
super()._recalculate(flows)
|
||||
app.ClientConnection.broadcast(
|
||||
type="UPDATE_FLOWS",
|
||||
cmd="reset"
|
||||
@ -61,7 +60,7 @@ class WebFlowView(flow.FlowView):
|
||||
class WebState(flow.State):
|
||||
|
||||
def __init__(self):
|
||||
super(WebState, self).__init__()
|
||||
super().__init__()
|
||||
self.view._close()
|
||||
self.view = WebFlowView(self.flows)
|
||||
|
||||
@ -83,7 +82,7 @@ class WebState(flow.State):
|
||||
)
|
||||
|
||||
def clear(self):
|
||||
super(WebState, self).clear()
|
||||
super().clear()
|
||||
self.events.clear()
|
||||
app.ClientConnection.broadcast(
|
||||
type="UPDATE_EVENTLOG",
|
||||
@ -111,7 +110,7 @@ class Options(options.Options):
|
||||
self.wsingleuser = wsingleuser
|
||||
self.whtpasswd = whtpasswd
|
||||
self.intercept = intercept
|
||||
super(Options, self).__init__(**kwargs)
|
||||
super().__init__(**kwargs)
|
||||
|
||||
# TODO: This doesn't belong here.
|
||||
def process_web_options(self, parser):
|
||||
@ -135,7 +134,7 @@ class Options(options.Options):
|
||||
class WebMaster(flow.FlowMaster):
|
||||
|
||||
def __init__(self, server, options):
|
||||
super(WebMaster, self).__init__(options, server, WebState())
|
||||
super().__init__(options, server, WebState())
|
||||
self.addons.add(*builtins.default_addons())
|
||||
self.app = app.Application(
|
||||
self, self.options.wdebug, self.options.wauthenticator
|
||||
@ -187,19 +186,19 @@ class WebMaster(flow.FlowMaster):
|
||||
|
||||
@controller.handler
|
||||
def request(self, f):
|
||||
super(WebMaster, self).request(f)
|
||||
super().request(f)
|
||||
return self._process_flow(f)
|
||||
|
||||
@controller.handler
|
||||
def response(self, f):
|
||||
super(WebMaster, self).response(f)
|
||||
super().response(f)
|
||||
return self._process_flow(f)
|
||||
|
||||
@controller.handler
|
||||
def error(self, f):
|
||||
super(WebMaster, self).error(f)
|
||||
super().error(f)
|
||||
return self._process_flow(f)
|
||||
|
||||
def add_log(self, e, level="info"):
|
||||
super(WebMaster, self).add_log(e, level)
|
||||
super().add_log(e, level)
|
||||
return self.state.add_log(e, level)
|
||||
|
@ -1 +0,0 @@
|
||||
from __future__ import (absolute_import, print_function, division)
|
@ -4,7 +4,7 @@ import threading
|
||||
|
||||
class BaseThread(threading.Thread):
|
||||
def __init__(self, name, *args, **kwargs):
|
||||
super(BaseThread, self).__init__(name=name, *args, **kwargs)
|
||||
super().__init__(name=name, *args, **kwargs)
|
||||
self._thread_started = time.time()
|
||||
|
||||
def _threadinfo(self):
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import (absolute_import, print_function, division)
|
||||
import os
|
||||
import ssl
|
||||
import time
|
||||
@ -155,7 +154,7 @@ def dummy_cert(privkey, cacert, commonname, sans):
|
||||
# return current.value
|
||||
|
||||
|
||||
class CertStoreEntry(object):
|
||||
class CertStoreEntry:
|
||||
|
||||
def __init__(self, cert, privatekey, chain_file):
|
||||
self.cert = cert
|
||||
@ -163,7 +162,7 @@ class CertStoreEntry(object):
|
||||
self.chain_file = chain_file
|
||||
|
||||
|
||||
class CertStore(object):
|
||||
class CertStore:
|
||||
|
||||
"""
|
||||
Implements an in-memory certificate store.
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import (absolute_import, print_function, division)
|
||||
|
||||
import gc
|
||||
import os
|
||||
|
@ -1,7 +1,6 @@
|
||||
"""
|
||||
Utility functions for decoding response bodies.
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
import codecs
|
||||
import collections
|
||||
|
@ -5,7 +5,6 @@ Every Exception netlib raises shall be a subclass of NetlibException.
|
||||
|
||||
See also: http://lucumr.pocoo.org/2014/10/16/on-error-handling/
|
||||
"""
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
|
||||
class NetlibException(Exception):
|
||||
@ -13,10 +12,10 @@ class NetlibException(Exception):
|
||||
Base class for all exceptions thrown by netlib.
|
||||
"""
|
||||
def __init__(self, message=None):
|
||||
super(NetlibException, self).__init__(message)
|
||||
super().__init__(message)
|
||||
|
||||
|
||||
class Disconnect(object):
|
||||
class Disconnect:
|
||||
"""Immediate EOF"""
|
||||
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
from netlib.http.request import Request
|
||||
from netlib.http.response import Response
|
||||
from netlib.http.message import Message
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import (absolute_import, print_function, division)
|
||||
import argparse
|
||||
import binascii
|
||||
|
||||
@ -23,7 +22,7 @@ def assemble_http_basic_auth(scheme, username, password):
|
||||
return scheme + " " + v
|
||||
|
||||
|
||||
class NullProxyAuth(object):
|
||||
class NullProxyAuth:
|
||||
|
||||
"""
|
||||
No proxy auth at all (returns empty challange headers)
|
||||
@ -90,7 +89,7 @@ class BasicProxyAuth(BasicAuth):
|
||||
AUTH_HEADER = 'Proxy-Authorization'
|
||||
|
||||
|
||||
class PassMan(object):
|
||||
class PassMan:
|
||||
|
||||
def test(self, username_, password_token_):
|
||||
return False
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import re
|
||||
|
||||
@ -77,7 +76,7 @@ class Headers(multidict.MultiDict):
|
||||
If ``**headers`` contains multiple keys that have equal ``.lower()`` s,
|
||||
the behavior is undefined.
|
||||
"""
|
||||
super(Headers, self).__init__(fields)
|
||||
super().__init__(fields)
|
||||
|
||||
for key, value in self.fields:
|
||||
if not isinstance(key, bytes) or not isinstance(value, bytes):
|
||||
@ -108,10 +107,10 @@ class Headers(multidict.MultiDict):
|
||||
|
||||
def __delitem__(self, key):
|
||||
key = _always_bytes(key)
|
||||
super(Headers, self).__delitem__(key)
|
||||
super().__delitem__(key)
|
||||
|
||||
def __iter__(self):
|
||||
for x in super(Headers, self).__iter__():
|
||||
for x in super().__iter__():
|
||||
yield _native(x)
|
||||
|
||||
def get_all(self, name):
|
||||
@ -123,7 +122,7 @@ class Headers(multidict.MultiDict):
|
||||
name = _always_bytes(name)
|
||||
return [
|
||||
_native(x) for x in
|
||||
super(Headers, self).get_all(name)
|
||||
super().get_all(name)
|
||||
]
|
||||
|
||||
def set_all(self, name, values):
|
||||
@ -133,12 +132,12 @@ class Headers(multidict.MultiDict):
|
||||
"""
|
||||
name = _always_bytes(name)
|
||||
values = [_always_bytes(x) for x in values]
|
||||
return super(Headers, self).set_all(name, values)
|
||||
return super().set_all(name, values)
|
||||
|
||||
def insert(self, index, key, value):
|
||||
key = _always_bytes(key)
|
||||
value = _always_bytes(value)
|
||||
super(Headers, self).insert(index, key, value)
|
||||
super().insert(index, key, value)
|
||||
|
||||
def items(self, multi=False):
|
||||
if multi:
|
||||
@ -147,7 +146,7 @@ class Headers(multidict.MultiDict):
|
||||
for k, v in self.fields
|
||||
)
|
||||
else:
|
||||
return super(Headers, self).items()
|
||||
return super().items()
|
||||
|
||||
def replace(self, pattern, repl, flags=0, count=0):
|
||||
"""
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
from .read import (
|
||||
read_request, read_request_head,
|
||||
read_response, read_response_head,
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import netlib.http.url
|
||||
from netlib import exceptions
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
import time
|
||||
import sys
|
||||
import re
|
||||
|
@ -1,4 +1,3 @@
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
from netlib.http.http2.framereader import read_raw_frame, parse_frame
|
||||
from netlib.http.http2.utils import parse_headers
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user