Skip to content

Commit

Permalink
[logger] log version_information events
Browse files Browse the repository at this point in the history
Use more events from qlog draft for easier debugging.
  • Loading branch information
pyfisch authored and jlaine committed Dec 12, 2023
1 parent a6a6983 commit 094b01d
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions src/aioquic/quic/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,18 @@ def receive_datagram(self, data: bytes, addr: NetworkAddress, now: float) -> Non
common = [
x for x in self._configuration.supported_versions if x in versions
]
if not common:
chosen_version = common[0] if common else None
if self._quic_logger is not None:
self._quic_logger.log_event(
category="transport",
event="version_information",
data={
"server_versions": versions,
"client_versions": self._configuration.supported_versions,
"chosen_version": chosen_version,
},
)
if chosen_version is None:
self._logger.error("Could not find a common protocol version")
self._close_event = events.ConnectionTerminated(
error_code=QuicErrorCode.INTERNAL_ERROR,
Expand All @@ -812,7 +823,7 @@ def receive_datagram(self, data: bytes, addr: NetworkAddress, now: float) -> Non
self._close_end()
return
self._packet_number = 0
self._version = QuicProtocolVersion(common[0])
self._version = QuicProtocolVersion(chosen_version)
self._version_negotiation_count += 1
self._logger.info("Retrying with %s", self._version)
self._connect(now=now)
Expand Down Expand Up @@ -1203,6 +1214,21 @@ def _connect(self, now: float) -> None:
"""
assert self._is_client

if self._quic_logger is not None:
self._quic_logger.log_event(
category="transport",
event="version_information",
data={
"client_versions": self._configuration.supported_versions,
"chosen_version": self._version,
},
)
self._quic_logger.log_event(
category="transport",
event="alpn_information",
data={"client_alpns": self._configuration.alpn_protocols},
)

self._close_at = now + self._configuration.idle_timeout
self._initialize(self._peer_cid.cid)

Expand Down

0 comments on commit 094b01d

Please sign in to comment.