示例#1
0
class ProxyController(mitmproxy.flow.FlowMaster):
    def __init__(self, server, state=None):
        from log import ProxyLogger

        if state is None:
            state = mitmproxy.flow.State()

        mitmproxy.flow.FlowMaster.__init__(self, server, state)

        self.logger = ProxyLogger('warning')

        self.ipc = IPCManager()

    def add_pipe(self, pipe):
        pipe.set_master(self)
        self.scripts.append(pipe)

    def handle_serverconnect(self, server_conn):
        # server_conn.__class__ = ServerConnection
        mproxy.flow.FlowMaster.handle_serverconnect(self, server_conn)

    def handle_request(self, f):
        mproxy.flow.FlowMaster.handle_request(self, f)
        if f and not (hasattr(f, 'should_reply') and f.should_reply is False):
            f.reply()
        return f

    def handle_response(self, f):
        mproxy.flow.FlowMaster.handle_response(self, f)
        if f:
            f.reply()
        return f

    def handle_error(self, f):
        mproxy.flow.FlowMaster.handle_error(self, f)
        return f

    def handle_next_layer(self, top_layer):
        if top_layer.__class__ == mproxy.protocol.TlsLayer:
            top_layer.__class__ = TlsLayer
        mproxy.flow.FlowMaster.handle_next_layer(self, top_layer)

    def add_event(self, e, level=None, key=None):
        self.logger.log(e, level, key)

    def run(self):
        self.run_script_hook('start')
        super(ProxyController, self).run()
示例#2
0
    def __init__(self, server, state=None):
        from log import ProxyLogger

        if state is None:
            state = mitmproxy.flow.State()

        mitmproxy.flow.FlowMaster.__init__(self, server, state)

        self.logger = ProxyLogger('warning')

        self.ipc = IPCManager()