This layer establishes QUIC for a single server connection.
| 359 | |
| 360 | |
| 361 | class 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 | |
| 404 | class ClientQuicLayer(QuicLayer): |
no outgoing calls
searching dependent graphs…