MCPcopy Index your code
hub / github.com/mitmproxy/mitmproxy / next_layer

Function next_layer

examples/contrib/custom_next_layer.py:25–42  ·  view source on GitHub ↗
(nextlayer: layer.NextLayer)

Source from the content-addressed store, hash-verified

23
24
25def next_layer(nextlayer: layer.NextLayer):
26 logging.info(
27 f"{nextlayer.context=}\n"
28 f"{nextlayer.data_client()[:70]=}\n"
29 f"{nextlayer.data_server()[:70]=}\n"
30 )
31
32 if nextlayer.context.server.address == ("example.com", 443):
33 nextlayer.context.server.address = ("example.com", 80)
34
35 # We are disabling ALPN negotiation as our curl client would otherwise agree on HTTP/2,
36 # which our example server here does not accept for plaintext connections.
37 nextlayer.context.client.alpn = b""
38
39 # We know all layers that come next: First negotiate TLS with the client, then do simple TCP passthrough.
40 # Setting only one layer here would also work, in that case next_layer would be called again after TLS establishment.
41 nextlayer.layer = layers.ClientTLSLayer(nextlayer.context)
42 nextlayer.layer.child_layer = layers.TCPLayer(nextlayer.context)

Callers

nothing calls this directly

Calls 3

infoMethod · 0.80
data_clientMethod · 0.80
data_serverMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…