aboutsummaryrefslogtreecommitdiffstats
path: root/test/mitmproxy/data/addonscripts/recorder.py
blob: fe497b05a9ac50327e225acf387d8239fd52c2be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from mitmproxy import controller
from mitmproxy import eventsequence
from mitmproxy import ctx
import sys


class CallLogger:
    call_log = []

    def __init__(self, name = "solo"):
        self.name = name

    def __getattr__(self, attr):
        if attr in eventsequence.Events:
            def prox(*args, **kwargs):
                lg = (self.name, attr, args, kwargs)
                if attr != "log":
                    ctx.log.info(str(lg))
                    self.call_log.append(lg)
                    ctx.log.debug("%s %s" % (self.name, attr))
            return prox
        raise AttributeError


def load(l):
    l.boot_into(CallLogger(*sys.argv[1:]))