Skip to content

Commit

Permalink
[connection] use frame_type=PADDING for CONNECTION_CLOSE
Browse files Browse the repository at this point in the history
When sending a CONNECTION_CLOSE from the QUIC layer, set the frame
type to PADDING if unknown.
  • Loading branch information
jlaine committed Mar 8, 2021
1 parent 9baf0c9 commit 426594d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/aioquic/quic/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ def handle_timer(self, now: float) -> None:
if self._close_event is None:
self._close_event = events.ConnectionTerminated(
error_code=QuicErrorCode.INTERNAL_ERROR,
frame_type=None,
frame_type=QuicFrameType.PADDING,
reason_phrase="Idle timeout",
)
self._close_end()
Expand Down Expand Up @@ -742,7 +742,7 @@ def receive_datagram(self, data: bytes, addr: NetworkAddress, now: float) -> Non
self._logger.error("Could not find a common protocol version")
self._close_event = events.ConnectionTerminated(
error_code=QuicErrorCode.INTERNAL_ERROR,
frame_type=None,
frame_type=QuicFrameType.PADDING,
reason_phrase="Could not find a common protocol version",
)
self._close_end()
Expand Down Expand Up @@ -858,7 +858,7 @@ def receive_datagram(self, data: bytes, addr: NetworkAddress, now: float) -> Non
if plain_header[0] & reserved_mask:
self.close(
error_code=QuicErrorCode.PROTOCOL_VIOLATION,
frame_type=None,
frame_type=QuicFrameType.PADDING,
reason_phrase="Reserved bits must be zero",
)
return
Expand Down
4 changes: 2 additions & 2 deletions tests/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,7 @@ def encrypt_packet(plain_header, plain_payload, packet_number):
client._close_event,
events.ConnectionTerminated(
error_code=QuicErrorCode.PROTOCOL_VIOLATION,
frame_type=None,
frame_type=QuicFrameType.PADDING,
reason_phrase="Reserved bits must be zero",
),
)
Expand Down Expand Up @@ -2292,7 +2292,7 @@ def test_version_negotiation_fail(self):
event = client.next_event()
self.assertEqual(type(event), events.ConnectionTerminated)
self.assertEqual(event.error_code, QuicErrorCode.INTERNAL_ERROR)
self.assertEqual(event.frame_type, None)
self.assertEqual(event.frame_type, QuicFrameType.PADDING)
self.assertEqual(
event.reason_phrase, "Could not find a common protocol version"
)
Expand Down

0 comments on commit 426594d

Please sign in to comment.