def next_layer(self, nextlayer: layer.NextLayer): if nextlayer.layer is None: nextlayer.layer = self._next_layer( nextlayer.context, nextlayer.data_client(), nextlayer.data_server(), )
def next_layer(nextlayer: layer.NextLayer): ctx.log(f"{nextlayer.context=}\n" f"{nextlayer.data_client()[:70]=}\n" f"{nextlayer.data_server()[:70]=}\n") if nextlayer.context.server.address == ("example.com", 443): nextlayer.context.server.address = ("example.com", 80) # We are disabling ALPN negotiation as our curl client would otherwise agree on HTTP/2, # which our example server here does not accept for plaintext connections. nextlayer.context.client.alpn = b"" # We know all layers that come next: First negotiate TLS with the client, then do simple TCP passthrough. # Setting only one layer here would also work, in that case next_layer would be called again after TLS establishment. nextlayer.layer = layers.ClientTLSLayer(nextlayer.context) nextlayer.layer.child_layer = layers.TCPLayer(nextlayer.context)
def next_layer(nl: layer.NextLayer): l = layer_stack.pop(0)(nl.context) l.debug = " " * len(nl.context.layers) nl.layer = l
def set_layer(next_layer: layer.NextLayer) -> None: next_layer.layer = child_layer(next_layer.context)