MCPcopy Create free account
hub / github.com/mitmproxy/mitmproxy / ServerQuicLayer

Class ServerQuicLayer

mitmproxy/proxy/layers/quic/_stream_layers.py:361–401  ·  view source on GitHub ↗

This layer establishes QUIC for a single server connection.

Source from the content-addressed store, hash-verified

359
360
361class ServerQuicLayer(QuicLayer):
362 """
363 This layer establishes QUIC for a single server connection.
364 """
365
366 wait_for_clienthello: bool = False
367
368 def __init__(
369 self,
370 context: context.Context,
371 conn: connection.Server | None = None,
372 time: Callable[[], float] | None = None,
373 ):
374 super().__init__(context, conn or context.server, time)
375
376 def start_handshake(self) -> layer.CommandGenerator[None]:
377 wait_for_clienthello = not self.command_to_reply_to and isinstance(
378 self.child_layer, ClientQuicLayer
379 )
380 if wait_for_clienthello:
381 self.wait_for_clienthello = True
382 self.tunnel_state = tunnel.TunnelState.CLOSED
383 else:
384 yield from self.start_tls(None)
385
386 def event_to_child(self, event: events.Event) -> layer.CommandGenerator[None]:
387 if self.wait_for_clienthello:
388 for command in super().event_to_child(event):
389 if (
390 isinstance(command, commands.OpenConnection)
391 and command.connection == self.conn
392 ):
393 self.wait_for_clienthello = False
394 else:
395 yield command
396 else:
397 yield from super().event_to_child(event)
398
399 def on_handshake_error(self, err: str) -> layer.CommandGenerator[None]:
400 yield commands.Log(f"Server QUIC handshake failed. {err}", level=WARNING)
401 yield from super().on_handshake_error(err)
402
403
404class ClientQuicLayer(QuicLayer):

Callers 7

test_reprMethod · 0.90
test_not_connectedMethod · 0.90
test_simpleMethod · 0.90
test_untrusted_certMethod · 0.90
make_client_tls_layerFunction · 0.90
_next_layerMethod · 0.90
_setup_reverse_proxyMethod · 0.90

Calls

no outgoing calls

Tested by 5

test_reprMethod · 0.72
test_not_connectedMethod · 0.72
test_simpleMethod · 0.72
test_untrusted_certMethod · 0.72
make_client_tls_layerFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…