MCPcopy
hub / github.com/mitmproxy/mitmproxy / TTunnelLayer

Class TTunnelLayer

test/mitmproxy/proxy/test_tunnel.py:43–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41
42
43class TTunnelLayer(tunnel.TunnelLayer):
44 def start_handshake(self) -> layer.CommandGenerator[None]:
45 yield SendData(self.tunnel_connection, b"handshake-hello")
46
47 def receive_handshake_data(
48 self, data: bytes
49 ) -> layer.CommandGenerator[tuple[bool, str | None]]:
50 yield SendData(self.tunnel_connection, data)
51 if data == b"handshake-success":
52 return True, None
53 else:
54 return False, "handshake error"
55
56 def send_data(self, data: bytes) -> layer.CommandGenerator[None]:
57 yield SendData(self.tunnel_connection, b"tunneled-" + data)
58
59 def receive_data(self, data: bytes) -> layer.CommandGenerator[None]:
60 yield from self.event_to_child(
61 DataReceived(self.conn, data.replace(b"tunneled-", b""))
62 )
63
64
65@pytest.mark.parametrize("success", ["success", "fail"])

Calls

no outgoing calls

Used in the wild real call sites across dependent graphs

searching dependent graphs…