path
stringlengths 9
117
| type
stringclasses 2
values | project
stringclasses 10
values | commit_hash
stringlengths 40
40
| commit_message
stringlengths 1
137
| ground_truth
stringlengths 0
2.74k
| main_code
stringlengths 102
3.37k
| context
stringlengths 0
14.7k
|
---|---|---|---|---|---|---|---|
aioquic.quic.connection/QuicConnection._handle_max_streams_uni_frame
|
Modified
|
aiortc~aioquic
|
5df513ec4d4581d072fb2b3d09d4f23c5a88a1b4
|
[qlog] log more frames
|
<6>:<add>
<add> # log frame
<add> if self._quic_logger is not None:
<add> context.quic_logger_frames.append(
<add> self._quic_logger.encode_max_streams_frame(maximum=max_streams)
<add> )
<add>
|
# module: aioquic.quic.connection
class QuicConnection:
def _handle_max_streams_uni_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
<0> """
<1> Handle a MAX_STREAMS_UNI frame.
<2>
<3> This raises number of unidirectional streams we can initiate to the peer.
<4> """
<5> max_streams = buf.pull_uint_var()
<6> if max_streams > self._remote_max_streams_uni:
<7> self._logger.debug("Remote max_streams_uni raised to %d", max_streams)
<8> self._remote_max_streams_uni = max_streams
<9> self._unblock_streams(is_unidirectional=True)
<10>
|
===========unchanged ref 0===========
at: aioquic._buffer.Buffer
pull_uint_var() -> int
at: aioquic.quic.connection.QuicConnection.__init__
self._quic_logger = configuration.quic_logger
at: aioquic.quic.connection.QuicReceiveContext
quic_logger_frames: Optional[List[Any]]
===========changed ref 0===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_data_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a DATA_BLOCKED frame.
"""
+ limit = buf.pull_uint_var()
- buf.pull_uint_var() # limit
===========changed ref 1===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_max_streams_bidi_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a MAX_STREAMS_BIDI frame.
This raises number of bidirectional streams we can initiate to the peer.
"""
max_streams = buf.pull_uint_var()
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_max_streams_frame(maximum=max_streams)
+ )
+
if max_streams > self._remote_max_streams_bidi:
self._logger.debug("Remote max_streams_bidi raised to %d", max_streams)
self._remote_max_streams_bidi = max_streams
self._unblock_streams(is_unidirectional=False)
===========changed ref 2===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_max_data_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a MAX_DATA frame.
This adjusts the total amount of we can send to the peer.
"""
max_data = buf.pull_uint_var()
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_max_data_frame(maximum=max_data)
+ )
+
if max_data > self._remote_max_data:
self._logger.debug("Remote max_data raised to %d", max_data)
self._remote_max_data = max_data
===========changed ref 3===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_max_stream_data_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a MAX_STREAM_DATA frame.
This adjusts the amount of data we can send on a specific stream.
"""
stream_id = buf.pull_uint_var()
max_stream_data = buf.pull_uint_var()
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_max_stream_data_frame(
+ maximum=max_stream_data, stream_id=stream_id
+ )
+ )
# check stream direction
self._assert_stream_can_send(frame_type, stream_id)
stream = self._get_or_create_stream(frame_type, stream_id)
if max_stream_data > stream.max_stream_data_remote:
self._logger.debug(
"Stream %d remote max_stream_data raised to %d",
stream_id,
max_stream_data,
)
stream.max_stream_data_remote = max_stream_data
===========changed ref 4===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_connection_close_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a CONNECTION_CLOSE frame.
"""
if frame_type == QuicFrameType.TRANSPORT_CLOSE:
error_code, frame_type, reason_phrase = pull_transport_close_frame(buf)
else:
error_code, reason_phrase = pull_application_close_frame(buf)
frame_type = None
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_connection_close_frame(
+ error_code=error_code,
+ frame_type=frame_type,
+ reason_phrase=reason_phrase,
+ )
+ )
+
self._logger.info(
"Connection close code 0x%X, reason %s", error_code, reason_phrase
)
self._close_event = events.ConnectionTerminated(
error_code=error_code, frame_type=frame_type, reason_phrase=reason_phrase
)
self._close_begin(is_initiator=False, now=context.time)
===========changed ref 5===========
# module: aioquic.quic.logger
+ def hexdump(data: bytes) -> str:
+ return binascii.hexlify(data).decode("ascii")
+
===========changed ref 6===========
# module: aioquic.quic.logger
class QuicLogger:
+ def encode_max_data_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "MAX_DATA", "maximum": str(maximum)}
+
===========changed ref 7===========
# module: aioquic.quic.logger
class QuicLogger:
+ def encode_max_streams_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "MAX_STREAMS", "maximum": str(maximum)}
+
===========changed ref 8===========
# module: aioquic.quic.logger
class QuicLogger:
+ def encode_data_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "DATA_BLOCKED", "limit": str(limit)}
+
===========changed ref 9===========
# module: aioquic.quic.logger
class QuicLogger:
+ def encode_streams_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "STREAMS_BLOCKED", "limit": str(limit)}
+
===========changed ref 10===========
# module: aioquic.quic.logger
class QuicLogger:
+ def encode_path_response_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "PATH_RESPONSE"}
+
===========changed ref 11===========
# module: aioquic.quic.logger
class QuicLogger:
+ def encode_path_challenge_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "PATH_CHALLENGE"}
+
===========changed ref 12===========
# module: aioquic.quic.packet
+ @dataclass
+ class QuicNewConnectionIdFrame:
+ sequence_number: int
+ retire_prior_to: int
+ connection_id: bytes
+ stateless_reset_token: bytes
+
===========changed ref 13===========
# module: aioquic.quic.logger
class QuicLogger:
+ def encode_retire_connection_id_frame(self, sequence_number: int) -> Dict:
+ return {
+ "frame_type": "RETIRE_CONNECTION_ID",
+ "sequence_number": str(sequence_number),
+ }
+
===========changed ref 14===========
# module: aioquic.quic.logger
class QuicLogger:
+ def encode_new_token_frame(self, token: bytes) -> Dict:
+ return {
+ "frame_type": "NEW_TOKEN",
+ "length": str(len(token)),
+ "token": hexdump(token),
+ }
+
|
aioquic.quic.connection/QuicConnection._handle_new_connection_id_frame
|
Modified
|
aiortc~aioquic
|
5df513ec4d4581d072fb2b3d09d4f23c5a88a1b4
|
[qlog] log more frames
|
<3>:<add> frame = pull_new_connection_id_frame(buf)
<add>
<add> # log frame
<add> if self._quic_logger is not None:
<add> context.quic_logger_frames.append(
<add> self._quic_logger.encode_new_connection_id_frame(frame)
<del> sequence_number, retire_prior_to, cid, stateless_reset_token = pull_new_connection_id_frame(
<4>:<add> )
<del> buf
<5>:<del> )
<6>:<del> self._logger.debug(
<7>:<del> "New connection ID received %d %s", sequence_number, dump_cid(cid)
<8>:<del> )
<9>:<add>
<11>:<add> cid=frame.connection_id,
<del> cid=cid,
<12>:<add> sequence_number=frame.sequence_number,
<del> sequence_number=sequence_number,
<13>:<add> stateless_reset_token=frame.stateless_reset_token,
<del> stateless_reset_token=stateless_reset_token,
|
# module: aioquic.quic.connection
class QuicConnection:
def _handle_new_connection_id_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
<0> """
<1> Handle a NEW_CONNECTION_ID frame.
<2> """
<3> sequence_number, retire_prior_to, cid, stateless_reset_token = pull_new_connection_id_frame(
<4> buf
<5> )
<6> self._logger.debug(
<7> "New connection ID received %d %s", sequence_number, dump_cid(cid)
<8> )
<9> self._peer_cid_available.append(
<10> QuicConnectionId(
<11> cid=cid,
<12> sequence_number=sequence_number,
<13> stateless_reset_token=stateless_reset_token,
<14> )
<15> )
<16>
|
===========unchanged ref 0===========
at: aioquic._buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic._buffer.Buffer
pull_uint_var() -> int
at: aioquic.quic.connection
QuicReceiveContext(epoch: tls.Epoch, host_cid: bytes, network_path: QuicNetworkPath, quic_logger_frames: Optional[List[Any]], time: float)
at: aioquic.quic.connection.QuicConnection
_unblock_streams(self, is_unidirectional: bool) -> None
_unblock_streams(is_unidirectional: bool) -> None
at: aioquic.quic.connection.QuicConnection.__init__
self._quic_logger = configuration.quic_logger
self._logger = QuicConnectionAdapter(
logger, {"host_cid": dump_cid(self.host_cid)}
)
self._remote_max_streams_bidi = 0
at: aioquic.quic.connection.QuicConnection._handle_max_streams_bidi_frame
max_streams = buf.pull_uint_var()
at: aioquic.quic.connection.QuicReceiveContext
quic_logger_frames: Optional[List[Any]]
===========changed ref 0===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_data_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a DATA_BLOCKED frame.
"""
+ limit = buf.pull_uint_var()
- buf.pull_uint_var() # limit
===========changed ref 1===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_max_streams_uni_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a MAX_STREAMS_UNI frame.
This raises number of unidirectional streams we can initiate to the peer.
"""
max_streams = buf.pull_uint_var()
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_max_streams_frame(maximum=max_streams)
+ )
+
if max_streams > self._remote_max_streams_uni:
self._logger.debug("Remote max_streams_uni raised to %d", max_streams)
self._remote_max_streams_uni = max_streams
self._unblock_streams(is_unidirectional=True)
===========changed ref 2===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_max_streams_bidi_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a MAX_STREAMS_BIDI frame.
This raises number of bidirectional streams we can initiate to the peer.
"""
max_streams = buf.pull_uint_var()
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_max_streams_frame(maximum=max_streams)
+ )
+
if max_streams > self._remote_max_streams_bidi:
self._logger.debug("Remote max_streams_bidi raised to %d", max_streams)
self._remote_max_streams_bidi = max_streams
self._unblock_streams(is_unidirectional=False)
===========changed ref 3===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_max_data_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a MAX_DATA frame.
This adjusts the total amount of we can send to the peer.
"""
max_data = buf.pull_uint_var()
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_max_data_frame(maximum=max_data)
+ )
+
if max_data > self._remote_max_data:
self._logger.debug("Remote max_data raised to %d", max_data)
self._remote_max_data = max_data
===========changed ref 4===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_max_stream_data_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a MAX_STREAM_DATA frame.
This adjusts the amount of data we can send on a specific stream.
"""
stream_id = buf.pull_uint_var()
max_stream_data = buf.pull_uint_var()
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_max_stream_data_frame(
+ maximum=max_stream_data, stream_id=stream_id
+ )
+ )
# check stream direction
self._assert_stream_can_send(frame_type, stream_id)
stream = self._get_or_create_stream(frame_type, stream_id)
if max_stream_data > stream.max_stream_data_remote:
self._logger.debug(
"Stream %d remote max_stream_data raised to %d",
stream_id,
max_stream_data,
)
stream.max_stream_data_remote = max_stream_data
===========changed ref 5===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_connection_close_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a CONNECTION_CLOSE frame.
"""
if frame_type == QuicFrameType.TRANSPORT_CLOSE:
error_code, frame_type, reason_phrase = pull_transport_close_frame(buf)
else:
error_code, reason_phrase = pull_application_close_frame(buf)
frame_type = None
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_connection_close_frame(
+ error_code=error_code,
+ frame_type=frame_type,
+ reason_phrase=reason_phrase,
+ )
+ )
+
self._logger.info(
"Connection close code 0x%X, reason %s", error_code, reason_phrase
)
self._close_event = events.ConnectionTerminated(
error_code=error_code, frame_type=frame_type, reason_phrase=reason_phrase
)
self._close_begin(is_initiator=False, now=context.time)
===========changed ref 6===========
# module: aioquic.quic.logger
+ def hexdump(data: bytes) -> str:
+ return binascii.hexlify(data).decode("ascii")
+
===========changed ref 7===========
# module: aioquic.quic.logger
class QuicLogger:
+ def encode_max_data_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "MAX_DATA", "maximum": str(maximum)}
+
===========changed ref 8===========
# module: aioquic.quic.logger
class QuicLogger:
+ def encode_max_streams_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "MAX_STREAMS", "maximum": str(maximum)}
+
|
aioquic.quic.connection/QuicConnection._handle_new_token_frame
|
Modified
|
aiortc~aioquic
|
5df513ec4d4581d072fb2b3d09d4f23c5a88a1b4
|
[qlog] log more frames
|
<3>:<add> token = pull_new_token_frame(buf)
<del> pull_new_token_frame(buf)
|
# module: aioquic.quic.connection
class QuicConnection:
def _handle_new_token_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
<0> """
<1> Handle a NEW_TOKEN frame.
<2> """
<3> pull_new_token_frame(buf)
<4>
|
===========unchanged ref 0===========
at: aioquic._buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic.quic.connection
QuicReceiveContext(epoch: tls.Epoch, host_cid: bytes, network_path: QuicNetworkPath, quic_logger_frames: Optional[List[Any]], time: float)
at: aioquic.quic.connection.QuicConnection
_unblock_streams(self, is_unidirectional: bool) -> None
_unblock_streams(is_unidirectional: bool) -> None
at: aioquic.quic.connection.QuicConnection.__init__
self._logger = QuicConnectionAdapter(
logger, {"host_cid": dump_cid(self.host_cid)}
)
self._remote_max_streams_uni = 0
at: aioquic.quic.connection.QuicConnection._handle_max_streams_uni_frame
max_streams = buf.pull_uint_var()
===========changed ref 0===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_data_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a DATA_BLOCKED frame.
"""
+ limit = buf.pull_uint_var()
- buf.pull_uint_var() # limit
===========changed ref 1===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_max_streams_uni_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a MAX_STREAMS_UNI frame.
This raises number of unidirectional streams we can initiate to the peer.
"""
max_streams = buf.pull_uint_var()
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_max_streams_frame(maximum=max_streams)
+ )
+
if max_streams > self._remote_max_streams_uni:
self._logger.debug("Remote max_streams_uni raised to %d", max_streams)
self._remote_max_streams_uni = max_streams
self._unblock_streams(is_unidirectional=True)
===========changed ref 2===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_max_streams_bidi_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a MAX_STREAMS_BIDI frame.
This raises number of bidirectional streams we can initiate to the peer.
"""
max_streams = buf.pull_uint_var()
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_max_streams_frame(maximum=max_streams)
+ )
+
if max_streams > self._remote_max_streams_bidi:
self._logger.debug("Remote max_streams_bidi raised to %d", max_streams)
self._remote_max_streams_bidi = max_streams
self._unblock_streams(is_unidirectional=False)
===========changed ref 3===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_max_data_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a MAX_DATA frame.
This adjusts the total amount of we can send to the peer.
"""
max_data = buf.pull_uint_var()
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_max_data_frame(maximum=max_data)
+ )
+
if max_data > self._remote_max_data:
self._logger.debug("Remote max_data raised to %d", max_data)
self._remote_max_data = max_data
===========changed ref 4===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_new_connection_id_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a NEW_CONNECTION_ID frame.
"""
+ frame = pull_new_connection_id_frame(buf)
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_new_connection_id_frame(frame)
- sequence_number, retire_prior_to, cid, stateless_reset_token = pull_new_connection_id_frame(
+ )
- buf
- )
- self._logger.debug(
- "New connection ID received %d %s", sequence_number, dump_cid(cid)
- )
+
self._peer_cid_available.append(
QuicConnectionId(
+ cid=frame.connection_id,
- cid=cid,
+ sequence_number=frame.sequence_number,
- sequence_number=sequence_number,
+ stateless_reset_token=frame.stateless_reset_token,
- stateless_reset_token=stateless_reset_token,
)
)
===========changed ref 5===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_max_stream_data_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a MAX_STREAM_DATA frame.
This adjusts the amount of data we can send on a specific stream.
"""
stream_id = buf.pull_uint_var()
max_stream_data = buf.pull_uint_var()
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_max_stream_data_frame(
+ maximum=max_stream_data, stream_id=stream_id
+ )
+ )
# check stream direction
self._assert_stream_can_send(frame_type, stream_id)
stream = self._get_or_create_stream(frame_type, stream_id)
if max_stream_data > stream.max_stream_data_remote:
self._logger.debug(
"Stream %d remote max_stream_data raised to %d",
stream_id,
max_stream_data,
)
stream.max_stream_data_remote = max_stream_data
|
aioquic.quic.connection/QuicConnection._handle_path_challenge_frame
|
Modified
|
aiortc~aioquic
|
5df513ec4d4581d072fb2b3d09d4f23c5a88a1b4
|
[qlog] log more frames
|
<4>:<add>
<add> # log frame
<add> if self._quic_logger is not None:
<add> context.quic_logger_frames.append(
<add> self._quic_logger.encode_path_challenge_frame(data=data)
<add> )
<add>
|
# module: aioquic.quic.connection
class QuicConnection:
def _handle_path_challenge_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
<0> """
<1> Handle a PATH_CHALLENGE frame.
<2> """
<3> data = buf.pull_bytes(8)
<4> context.network_path.remote_challenge = data
<5>
|
===========unchanged ref 0===========
at: aioquic.quic.connection
QuicConnectionId(cid: bytes, sequence_number: int, stateless_reset_token: bytes=b"", was_sent: bool=False)
at: aioquic.quic.connection.QuicConnection._handle_new_connection_id_frame
frame = pull_new_connection_id_frame(buf)
at: aioquic.quic.connection.QuicConnectionId
cid: bytes
sequence_number: int
stateless_reset_token: bytes = b""
was_sent: bool = False
at: aioquic.quic.packet.QuicNewConnectionIdFrame
sequence_number: int
retire_prior_to: int
connection_id: bytes
stateless_reset_token: bytes
===========changed ref 0===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_new_token_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a NEW_TOKEN frame.
"""
+ token = pull_new_token_frame(buf)
- pull_new_token_frame(buf)
===========changed ref 1===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_data_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a DATA_BLOCKED frame.
"""
+ limit = buf.pull_uint_var()
- buf.pull_uint_var() # limit
===========changed ref 2===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_max_streams_uni_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a MAX_STREAMS_UNI frame.
This raises number of unidirectional streams we can initiate to the peer.
"""
max_streams = buf.pull_uint_var()
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_max_streams_frame(maximum=max_streams)
+ )
+
if max_streams > self._remote_max_streams_uni:
self._logger.debug("Remote max_streams_uni raised to %d", max_streams)
self._remote_max_streams_uni = max_streams
self._unblock_streams(is_unidirectional=True)
===========changed ref 3===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_max_streams_bidi_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a MAX_STREAMS_BIDI frame.
This raises number of bidirectional streams we can initiate to the peer.
"""
max_streams = buf.pull_uint_var()
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_max_streams_frame(maximum=max_streams)
+ )
+
if max_streams > self._remote_max_streams_bidi:
self._logger.debug("Remote max_streams_bidi raised to %d", max_streams)
self._remote_max_streams_bidi = max_streams
self._unblock_streams(is_unidirectional=False)
===========changed ref 4===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_max_data_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a MAX_DATA frame.
This adjusts the total amount of we can send to the peer.
"""
max_data = buf.pull_uint_var()
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_max_data_frame(maximum=max_data)
+ )
+
if max_data > self._remote_max_data:
self._logger.debug("Remote max_data raised to %d", max_data)
self._remote_max_data = max_data
===========changed ref 5===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_new_connection_id_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a NEW_CONNECTION_ID frame.
"""
+ frame = pull_new_connection_id_frame(buf)
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_new_connection_id_frame(frame)
- sequence_number, retire_prior_to, cid, stateless_reset_token = pull_new_connection_id_frame(
+ )
- buf
- )
- self._logger.debug(
- "New connection ID received %d %s", sequence_number, dump_cid(cid)
- )
+
self._peer_cid_available.append(
QuicConnectionId(
+ cid=frame.connection_id,
- cid=cid,
+ sequence_number=frame.sequence_number,
- sequence_number=sequence_number,
+ stateless_reset_token=frame.stateless_reset_token,
- stateless_reset_token=stateless_reset_token,
)
)
===========changed ref 6===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_max_stream_data_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a MAX_STREAM_DATA frame.
This adjusts the amount of data we can send on a specific stream.
"""
stream_id = buf.pull_uint_var()
max_stream_data = buf.pull_uint_var()
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_max_stream_data_frame(
+ maximum=max_stream_data, stream_id=stream_id
+ )
+ )
# check stream direction
self._assert_stream_can_send(frame_type, stream_id)
stream = self._get_or_create_stream(frame_type, stream_id)
if max_stream_data > stream.max_stream_data_remote:
self._logger.debug(
"Stream %d remote max_stream_data raised to %d",
stream_id,
max_stream_data,
)
stream.max_stream_data_remote = max_stream_data
|
aioquic.quic.connection/QuicConnection._handle_path_response_frame
|
Modified
|
aiortc~aioquic
|
5df513ec4d4581d072fb2b3d09d4f23c5a88a1b4
|
[qlog] log more frames
|
<4>:<add>
<add> # log frame
<add> if self._quic_logger is not None:
<add> context.quic_logger_frames.append(
<add> self._quic_logger.encode_path_response_frame(data=data)
<add> )
<add>
|
# module: aioquic.quic.connection
class QuicConnection:
def _handle_path_response_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
<0> """
<1> Handle a PATH_RESPONSE frame.
<2> """
<3> data = buf.pull_bytes(8)
<4> if data != context.network_path.local_challenge:
<5> raise QuicConnectionError(
<6> error_code=QuicErrorCode.PROTOCOL_VIOLATION,
<7> frame_type=frame_type,
<8> reason_phrase="Response does not match challenge",
<9> )
<10> self._logger.info(
<11> "Network path %s validated by challenge", context.network_path.addr
<12> )
<13> context.network_path.is_validated = True
<14>
|
===========unchanged ref 0===========
at: aioquic._buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic.quic.connection
QuicReceiveContext(epoch: tls.Epoch, host_cid: bytes, network_path: QuicNetworkPath, quic_logger_frames: Optional[List[Any]], time: float)
at: aioquic.quic.connection.QuicConnection.__init__
self._quic_logger = configuration.quic_logger
at: aioquic.quic.connection.QuicReceiveContext
quic_logger_frames: Optional[List[Any]]
at: aioquic.quic.packet
pull_new_token_frame(buf: Buffer) -> bytes
===========changed ref 0===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_new_token_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a NEW_TOKEN frame.
"""
+ token = pull_new_token_frame(buf)
- pull_new_token_frame(buf)
===========changed ref 1===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_path_challenge_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a PATH_CHALLENGE frame.
"""
data = buf.pull_bytes(8)
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_path_challenge_frame(data=data)
+ )
+
context.network_path.remote_challenge = data
===========changed ref 2===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_data_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a DATA_BLOCKED frame.
"""
+ limit = buf.pull_uint_var()
- buf.pull_uint_var() # limit
===========changed ref 3===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_max_streams_uni_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a MAX_STREAMS_UNI frame.
This raises number of unidirectional streams we can initiate to the peer.
"""
max_streams = buf.pull_uint_var()
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_max_streams_frame(maximum=max_streams)
+ )
+
if max_streams > self._remote_max_streams_uni:
self._logger.debug("Remote max_streams_uni raised to %d", max_streams)
self._remote_max_streams_uni = max_streams
self._unblock_streams(is_unidirectional=True)
===========changed ref 4===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_max_streams_bidi_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a MAX_STREAMS_BIDI frame.
This raises number of bidirectional streams we can initiate to the peer.
"""
max_streams = buf.pull_uint_var()
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_max_streams_frame(maximum=max_streams)
+ )
+
if max_streams > self._remote_max_streams_bidi:
self._logger.debug("Remote max_streams_bidi raised to %d", max_streams)
self._remote_max_streams_bidi = max_streams
self._unblock_streams(is_unidirectional=False)
===========changed ref 5===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_max_data_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a MAX_DATA frame.
This adjusts the total amount of we can send to the peer.
"""
max_data = buf.pull_uint_var()
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_max_data_frame(maximum=max_data)
+ )
+
if max_data > self._remote_max_data:
self._logger.debug("Remote max_data raised to %d", max_data)
self._remote_max_data = max_data
===========changed ref 6===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_new_connection_id_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a NEW_CONNECTION_ID frame.
"""
+ frame = pull_new_connection_id_frame(buf)
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_new_connection_id_frame(frame)
- sequence_number, retire_prior_to, cid, stateless_reset_token = pull_new_connection_id_frame(
+ )
- buf
- )
- self._logger.debug(
- "New connection ID received %d %s", sequence_number, dump_cid(cid)
- )
+
self._peer_cid_available.append(
QuicConnectionId(
+ cid=frame.connection_id,
- cid=cid,
+ sequence_number=frame.sequence_number,
- sequence_number=sequence_number,
+ stateless_reset_token=frame.stateless_reset_token,
- stateless_reset_token=stateless_reset_token,
)
)
===========changed ref 7===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_max_stream_data_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a MAX_STREAM_DATA frame.
This adjusts the amount of data we can send on a specific stream.
"""
stream_id = buf.pull_uint_var()
max_stream_data = buf.pull_uint_var()
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_max_stream_data_frame(
+ maximum=max_stream_data, stream_id=stream_id
+ )
+ )
# check stream direction
self._assert_stream_can_send(frame_type, stream_id)
stream = self._get_or_create_stream(frame_type, stream_id)
if max_stream_data > stream.max_stream_data_remote:
self._logger.debug(
"Stream %d remote max_stream_data raised to %d",
stream_id,
max_stream_data,
)
stream.max_stream_data_remote = max_stream_data
|
aioquic.quic.connection/QuicConnection._handle_reset_stream_frame
|
Modified
|
aiortc~aioquic
|
5df513ec4d4581d072fb2b3d09d4f23c5a88a1b4
|
[qlog] log more frames
|
<6>:<add>
<add> # log frame
<add> if self._quic_logger is not None:
<add> context.quic_logger_frames.append(
<add> self._quic_logger.encode_reset_stream_frame(
<add> error_code=error_code, final_size=final_size, stream_id=stream_id
<add> )
<add> )
|
# module: aioquic.quic.connection
class QuicConnection:
def _handle_reset_stream_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
<0> """
<1> Handle a RESET_STREAM frame.
<2> """
<3> stream_id = buf.pull_uint_var()
<4> error_code = buf.pull_uint_var()
<5> final_size = buf.pull_uint_var()
<6>
<7> # check stream direction
<8> self._assert_stream_can_receive(frame_type, stream_id)
<9>
<10> self._logger.info(
<11> "Stream %d reset by peer (error code %d, final size %d)",
<12> stream_id,
<13> error_code,
<14> final_size,
<15> )
<16> # stream = self._get_or_create_stream(frame_type, stream_id)
<17> self._events.append(events.StreamReset(stream_id=stream_id))
<18>
|
===========unchanged ref 0===========
at: aioquic._buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic._buffer.Buffer
pull_bytes(length: int) -> bytes
at: aioquic.quic.connection
QuicReceiveContext(epoch: tls.Epoch, host_cid: bytes, network_path: QuicNetworkPath, quic_logger_frames: Optional[List[Any]], time: float)
at: aioquic.quic.connection.QuicConnection.__init__
self._quic_logger = configuration.quic_logger
at: aioquic.quic.connection.QuicNetworkPath
addr: NetworkAddress
bytes_received: int = 0
bytes_sent: int = 0
is_validated: bool = False
local_challenge: Optional[bytes] = None
remote_challenge: Optional[bytes] = None
at: aioquic.quic.connection.QuicReceiveContext
network_path: QuicNetworkPath
quic_logger_frames: Optional[List[Any]]
===========changed ref 0===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_new_token_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a NEW_TOKEN frame.
"""
+ token = pull_new_token_frame(buf)
- pull_new_token_frame(buf)
===========changed ref 1===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_path_challenge_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a PATH_CHALLENGE frame.
"""
data = buf.pull_bytes(8)
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_path_challenge_frame(data=data)
+ )
+
context.network_path.remote_challenge = data
===========changed ref 2===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_data_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a DATA_BLOCKED frame.
"""
+ limit = buf.pull_uint_var()
- buf.pull_uint_var() # limit
===========changed ref 3===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_path_response_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a PATH_RESPONSE frame.
"""
data = buf.pull_bytes(8)
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_path_response_frame(data=data)
+ )
+
if data != context.network_path.local_challenge:
raise QuicConnectionError(
error_code=QuicErrorCode.PROTOCOL_VIOLATION,
frame_type=frame_type,
reason_phrase="Response does not match challenge",
)
self._logger.info(
"Network path %s validated by challenge", context.network_path.addr
)
context.network_path.is_validated = True
===========changed ref 4===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_max_streams_uni_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a MAX_STREAMS_UNI frame.
This raises number of unidirectional streams we can initiate to the peer.
"""
max_streams = buf.pull_uint_var()
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_max_streams_frame(maximum=max_streams)
+ )
+
if max_streams > self._remote_max_streams_uni:
self._logger.debug("Remote max_streams_uni raised to %d", max_streams)
self._remote_max_streams_uni = max_streams
self._unblock_streams(is_unidirectional=True)
===========changed ref 5===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_max_streams_bidi_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a MAX_STREAMS_BIDI frame.
This raises number of bidirectional streams we can initiate to the peer.
"""
max_streams = buf.pull_uint_var()
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_max_streams_frame(maximum=max_streams)
+ )
+
if max_streams > self._remote_max_streams_bidi:
self._logger.debug("Remote max_streams_bidi raised to %d", max_streams)
self._remote_max_streams_bidi = max_streams
self._unblock_streams(is_unidirectional=False)
===========changed ref 6===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_max_data_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a MAX_DATA frame.
This adjusts the total amount of we can send to the peer.
"""
max_data = buf.pull_uint_var()
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_max_data_frame(maximum=max_data)
+ )
+
if max_data > self._remote_max_data:
self._logger.debug("Remote max_data raised to %d", max_data)
self._remote_max_data = max_data
===========changed ref 7===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_new_connection_id_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a NEW_CONNECTION_ID frame.
"""
+ frame = pull_new_connection_id_frame(buf)
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_new_connection_id_frame(frame)
- sequence_number, retire_prior_to, cid, stateless_reset_token = pull_new_connection_id_frame(
+ )
- buf
- )
- self._logger.debug(
- "New connection ID received %d %s", sequence_number, dump_cid(cid)
- )
+
self._peer_cid_available.append(
QuicConnectionId(
+ cid=frame.connection_id,
- cid=cid,
+ sequence_number=frame.sequence_number,
- sequence_number=sequence_number,
+ stateless_reset_token=frame.stateless_reset_token,
- stateless_reset_token=stateless_reset_token,
)
)
|
aioquic.quic.connection/QuicConnection._handle_retire_connection_id_frame
|
Modified
|
aiortc~aioquic
|
5df513ec4d4581d072fb2b3d09d4f23c5a88a1b4
|
[qlog] log more frames
|
<4>:<add>
<add> # log frame
<add> if self._quic_logger is not None:
<add> context.quic_logger_frames.append(
<add> self._quic_logger.encode_retire_connection_id_frame(sequence_number)
<add> )
|
# module: aioquic.quic.connection
class QuicConnection:
def _handle_retire_connection_id_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
<0> """
<1> Handle a RETIRE_CONNECTION_ID frame.
<2> """
<3> sequence_number = buf.pull_uint_var()
<4>
<5> # find the connection ID by sequence number
<6> for index, connection_id in enumerate(self._host_cids):
<7> if connection_id.sequence_number == sequence_number:
<8> if connection_id.cid == context.host_cid:
<9> raise QuicConnectionError(
<10> error_code=QuicErrorCode.PROTOCOL_VIOLATION,
<11> frame_type=frame_type,
<12> reason_phrase="Cannot retire current connection ID",
<13> )
<14> del self._host_cids[index]
<15> self._events.append(
<16> events.ConnectionIdRetired(connection_id=connection_id.cid)
<17> )
<18> break
<19>
<20> # issue a new connection ID
<21> self._replenish_connection_ids()
<22>
|
===========unchanged ref 0===========
at: aioquic._buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic.quic.connection
QuicConnectionError(error_code: int, frame_type: int, reason_phrase: str)
QuicReceiveContext(epoch: tls.Epoch, host_cid: bytes, network_path: QuicNetworkPath, quic_logger_frames: Optional[List[Any]], time: float)
at: aioquic.quic.connection.QuicConnection.__init__
self._quic_logger = configuration.quic_logger
self._logger = QuicConnectionAdapter(
logger, {"host_cid": dump_cid(self.host_cid)}
)
at: aioquic.quic.connection.QuicConnection._handle_path_response_frame
data = buf.pull_bytes(8)
at: aioquic.quic.connection.QuicNetworkPath
addr: NetworkAddress
is_validated: bool = False
local_challenge: Optional[bytes] = None
at: aioquic.quic.connection.QuicReceiveContext
network_path: QuicNetworkPath
quic_logger_frames: Optional[List[Any]]
at: aioquic.quic.packet
QuicErrorCode(x: Union[str, bytes, bytearray], base: int)
QuicErrorCode(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
===========changed ref 0===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_new_token_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a NEW_TOKEN frame.
"""
+ token = pull_new_token_frame(buf)
- pull_new_token_frame(buf)
===========changed ref 1===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_path_challenge_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a PATH_CHALLENGE frame.
"""
data = buf.pull_bytes(8)
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_path_challenge_frame(data=data)
+ )
+
context.network_path.remote_challenge = data
===========changed ref 2===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_data_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a DATA_BLOCKED frame.
"""
+ limit = buf.pull_uint_var()
- buf.pull_uint_var() # limit
===========changed ref 3===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_path_response_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a PATH_RESPONSE frame.
"""
data = buf.pull_bytes(8)
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_path_response_frame(data=data)
+ )
+
if data != context.network_path.local_challenge:
raise QuicConnectionError(
error_code=QuicErrorCode.PROTOCOL_VIOLATION,
frame_type=frame_type,
reason_phrase="Response does not match challenge",
)
self._logger.info(
"Network path %s validated by challenge", context.network_path.addr
)
context.network_path.is_validated = True
===========changed ref 4===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_reset_stream_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a RESET_STREAM frame.
"""
stream_id = buf.pull_uint_var()
error_code = buf.pull_uint_var()
final_size = buf.pull_uint_var()
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_reset_stream_frame(
+ error_code=error_code, final_size=final_size, stream_id=stream_id
+ )
+ )
# check stream direction
self._assert_stream_can_receive(frame_type, stream_id)
self._logger.info(
"Stream %d reset by peer (error code %d, final size %d)",
stream_id,
error_code,
final_size,
)
# stream = self._get_or_create_stream(frame_type, stream_id)
self._events.append(events.StreamReset(stream_id=stream_id))
===========changed ref 5===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_max_streams_uni_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a MAX_STREAMS_UNI frame.
This raises number of unidirectional streams we can initiate to the peer.
"""
max_streams = buf.pull_uint_var()
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_max_streams_frame(maximum=max_streams)
+ )
+
if max_streams > self._remote_max_streams_uni:
self._logger.debug("Remote max_streams_uni raised to %d", max_streams)
self._remote_max_streams_uni = max_streams
self._unblock_streams(is_unidirectional=True)
===========changed ref 6===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_max_streams_bidi_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a MAX_STREAMS_BIDI frame.
This raises number of bidirectional streams we can initiate to the peer.
"""
max_streams = buf.pull_uint_var()
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_max_streams_frame(maximum=max_streams)
+ )
+
if max_streams > self._remote_max_streams_bidi:
self._logger.debug("Remote max_streams_bidi raised to %d", max_streams)
self._remote_max_streams_bidi = max_streams
self._unblock_streams(is_unidirectional=False)
|
aioquic.quic.connection/QuicConnection._handle_stop_sending_frame
|
Modified
|
aiortc~aioquic
|
5df513ec4d4581d072fb2b3d09d4f23c5a88a1b4
|
[qlog] log more frames
|
<4>:<add> error_code = buf.pull_uint_var() # application error code
<del> buf.pull_uint_var() # application error code
<5>:<add>
<add> # log frame
<add> if self._quic_logger is not None:
<add> context.quic_logger_frames.append(
<add> self._quic_logger.encode_stop_sending_frame(
<add> error_code=error_code, stream_id=stream_id
<add> )
<add> )
|
# module: aioquic.quic.connection
class QuicConnection:
def _handle_stop_sending_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
<0> """
<1> Handle a STOP_SENDING frame.
<2> """
<3> stream_id = buf.pull_uint_var()
<4> buf.pull_uint_var() # application error code
<5>
<6> # check stream direction
<7> self._assert_stream_can_send(frame_type, stream_id)
<8>
<9> self._get_or_create_stream(frame_type, stream_id)
<10>
|
===========unchanged ref 0===========
at: aioquic._buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic._buffer.Buffer
pull_uint_var() -> int
at: aioquic.quic.connection
QuicReceiveContext(epoch: tls.Epoch, host_cid: bytes, network_path: QuicNetworkPath, quic_logger_frames: Optional[List[Any]], time: float)
at: aioquic.quic.connection.QuicConnection.__init__
self._quic_logger = configuration.quic_logger
at: aioquic.quic.connection.QuicReceiveContext
quic_logger_frames: Optional[List[Any]]
===========changed ref 0===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_new_token_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a NEW_TOKEN frame.
"""
+ token = pull_new_token_frame(buf)
- pull_new_token_frame(buf)
===========changed ref 1===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_path_challenge_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a PATH_CHALLENGE frame.
"""
data = buf.pull_bytes(8)
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_path_challenge_frame(data=data)
+ )
+
context.network_path.remote_challenge = data
===========changed ref 2===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_data_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a DATA_BLOCKED frame.
"""
+ limit = buf.pull_uint_var()
- buf.pull_uint_var() # limit
===========changed ref 3===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_path_response_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a PATH_RESPONSE frame.
"""
data = buf.pull_bytes(8)
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_path_response_frame(data=data)
+ )
+
if data != context.network_path.local_challenge:
raise QuicConnectionError(
error_code=QuicErrorCode.PROTOCOL_VIOLATION,
frame_type=frame_type,
reason_phrase="Response does not match challenge",
)
self._logger.info(
"Network path %s validated by challenge", context.network_path.addr
)
context.network_path.is_validated = True
===========changed ref 4===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_retire_connection_id_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a RETIRE_CONNECTION_ID frame.
"""
sequence_number = buf.pull_uint_var()
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_retire_connection_id_frame(sequence_number)
+ )
# find the connection ID by sequence number
for index, connection_id in enumerate(self._host_cids):
if connection_id.sequence_number == sequence_number:
if connection_id.cid == context.host_cid:
raise QuicConnectionError(
error_code=QuicErrorCode.PROTOCOL_VIOLATION,
frame_type=frame_type,
reason_phrase="Cannot retire current connection ID",
)
del self._host_cids[index]
self._events.append(
events.ConnectionIdRetired(connection_id=connection_id.cid)
)
break
# issue a new connection ID
self._replenish_connection_ids()
===========changed ref 5===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_reset_stream_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a RESET_STREAM frame.
"""
stream_id = buf.pull_uint_var()
error_code = buf.pull_uint_var()
final_size = buf.pull_uint_var()
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_reset_stream_frame(
+ error_code=error_code, final_size=final_size, stream_id=stream_id
+ )
+ )
# check stream direction
self._assert_stream_can_receive(frame_type, stream_id)
self._logger.info(
"Stream %d reset by peer (error code %d, final size %d)",
stream_id,
error_code,
final_size,
)
# stream = self._get_or_create_stream(frame_type, stream_id)
self._events.append(events.StreamReset(stream_id=stream_id))
===========changed ref 6===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_max_streams_uni_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a MAX_STREAMS_UNI frame.
This raises number of unidirectional streams we can initiate to the peer.
"""
max_streams = buf.pull_uint_var()
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_max_streams_frame(maximum=max_streams)
+ )
+
if max_streams > self._remote_max_streams_uni:
self._logger.debug("Remote max_streams_uni raised to %d", max_streams)
self._remote_max_streams_uni = max_streams
self._unblock_streams(is_unidirectional=True)
===========changed ref 7===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_max_streams_bidi_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a MAX_STREAMS_BIDI frame.
This raises number of bidirectional streams we can initiate to the peer.
"""
max_streams = buf.pull_uint_var()
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_max_streams_frame(maximum=max_streams)
+ )
+
if max_streams > self._remote_max_streams_bidi:
self._logger.debug("Remote max_streams_bidi raised to %d", max_streams)
self._remote_max_streams_bidi = max_streams
self._unblock_streams(is_unidirectional=False)
|
aioquic.quic.connection/QuicConnection._handle_stream_data_blocked_frame
|
Modified
|
aiortc~aioquic
|
5df513ec4d4581d072fb2b3d09d4f23c5a88a1b4
|
[qlog] log more frames
|
<4>:<add> limit = buf.pull_uint_var()
<del> buf.pull_uint_var() # limit
<5>:<add>
<add> # log frame
<add> if self._quic_logger is not None:
<add> context.quic_logger_frames.append(
<add> self._quic_logger.encode_stream_data_blocked_frame(
<add> limit=limit, stream_id=stream_id
<add> )
<add> )
|
# module: aioquic.quic.connection
class QuicConnection:
def _handle_stream_data_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
<0> """
<1> Handle a STREAM_DATA_BLOCKED frame.
<2> """
<3> stream_id = buf.pull_uint_var()
<4> buf.pull_uint_var() # limit
<5>
<6> # check stream direction
<7> self._assert_stream_can_receive(frame_type, stream_id)
<8>
<9> self._get_or_create_stream(frame_type, stream_id)
<10>
|
===========unchanged ref 0===========
at: aioquic._buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic._buffer.Buffer
pull_uint_var() -> int
at: aioquic.quic.connection
QuicReceiveContext(epoch: tls.Epoch, host_cid: bytes, network_path: QuicNetworkPath, quic_logger_frames: Optional[List[Any]], time: float)
at: aioquic.quic.connection.QuicConnection.__init__
self._quic_logger = configuration.quic_logger
at: aioquic.quic.connection.QuicReceiveContext
quic_logger_frames: Optional[List[Any]]
===========changed ref 0===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_new_token_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a NEW_TOKEN frame.
"""
+ token = pull_new_token_frame(buf)
- pull_new_token_frame(buf)
===========changed ref 1===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_stop_sending_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a STOP_SENDING frame.
"""
stream_id = buf.pull_uint_var()
+ error_code = buf.pull_uint_var() # application error code
- buf.pull_uint_var() # application error code
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_stop_sending_frame(
+ error_code=error_code, stream_id=stream_id
+ )
+ )
# check stream direction
self._assert_stream_can_send(frame_type, stream_id)
self._get_or_create_stream(frame_type, stream_id)
===========changed ref 2===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_path_challenge_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a PATH_CHALLENGE frame.
"""
data = buf.pull_bytes(8)
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_path_challenge_frame(data=data)
+ )
+
context.network_path.remote_challenge = data
===========changed ref 3===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_data_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a DATA_BLOCKED frame.
"""
+ limit = buf.pull_uint_var()
- buf.pull_uint_var() # limit
===========changed ref 4===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_path_response_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a PATH_RESPONSE frame.
"""
data = buf.pull_bytes(8)
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_path_response_frame(data=data)
+ )
+
if data != context.network_path.local_challenge:
raise QuicConnectionError(
error_code=QuicErrorCode.PROTOCOL_VIOLATION,
frame_type=frame_type,
reason_phrase="Response does not match challenge",
)
self._logger.info(
"Network path %s validated by challenge", context.network_path.addr
)
context.network_path.is_validated = True
===========changed ref 5===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_retire_connection_id_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a RETIRE_CONNECTION_ID frame.
"""
sequence_number = buf.pull_uint_var()
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_retire_connection_id_frame(sequence_number)
+ )
# find the connection ID by sequence number
for index, connection_id in enumerate(self._host_cids):
if connection_id.sequence_number == sequence_number:
if connection_id.cid == context.host_cid:
raise QuicConnectionError(
error_code=QuicErrorCode.PROTOCOL_VIOLATION,
frame_type=frame_type,
reason_phrase="Cannot retire current connection ID",
)
del self._host_cids[index]
self._events.append(
events.ConnectionIdRetired(connection_id=connection_id.cid)
)
break
# issue a new connection ID
self._replenish_connection_ids()
===========changed ref 6===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_reset_stream_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a RESET_STREAM frame.
"""
stream_id = buf.pull_uint_var()
error_code = buf.pull_uint_var()
final_size = buf.pull_uint_var()
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_reset_stream_frame(
+ error_code=error_code, final_size=final_size, stream_id=stream_id
+ )
+ )
# check stream direction
self._assert_stream_can_receive(frame_type, stream_id)
self._logger.info(
"Stream %d reset by peer (error code %d, final size %d)",
stream_id,
error_code,
final_size,
)
# stream = self._get_or_create_stream(frame_type, stream_id)
self._events.append(events.StreamReset(stream_id=stream_id))
===========changed ref 7===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_max_streams_uni_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a MAX_STREAMS_UNI frame.
This raises number of unidirectional streams we can initiate to the peer.
"""
max_streams = buf.pull_uint_var()
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_max_streams_frame(maximum=max_streams)
+ )
+
if max_streams > self._remote_max_streams_uni:
self._logger.debug("Remote max_streams_uni raised to %d", max_streams)
self._remote_max_streams_uni = max_streams
self._unblock_streams(is_unidirectional=True)
|
aioquic.quic.connection/QuicConnection._handle_streams_blocked_frame
|
Modified
|
aiortc~aioquic
|
5df513ec4d4581d072fb2b3d09d4f23c5a88a1b4
|
[qlog] log more frames
|
<3>:<add> limit = buf.pull_uint_var()
<del> buf.pull_uint_var() # limit
|
# module: aioquic.quic.connection
class QuicConnection:
def _handle_streams_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
<0> """
<1> Handle a STREAMS_BLOCKED frame.
<2> """
<3> buf.pull_uint_var() # limit
<4>
|
===========unchanged ref 0===========
at: aioquic.quic.connection.QuicConnection
_assert_stream_can_send(frame_type: int, stream_id: int) -> None
_get_or_create_stream(frame_type: int, stream_id: int) -> QuicStream
at: aioquic.quic.connection.QuicConnection._handle_stop_sending_frame
stream_id = buf.pull_uint_var()
===========changed ref 0===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_stream_data_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a STREAM_DATA_BLOCKED frame.
"""
stream_id = buf.pull_uint_var()
+ limit = buf.pull_uint_var()
- buf.pull_uint_var() # limit
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_stream_data_blocked_frame(
+ limit=limit, stream_id=stream_id
+ )
+ )
# check stream direction
self._assert_stream_can_receive(frame_type, stream_id)
self._get_or_create_stream(frame_type, stream_id)
===========changed ref 1===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_new_token_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a NEW_TOKEN frame.
"""
+ token = pull_new_token_frame(buf)
- pull_new_token_frame(buf)
===========changed ref 2===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_stop_sending_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a STOP_SENDING frame.
"""
stream_id = buf.pull_uint_var()
+ error_code = buf.pull_uint_var() # application error code
- buf.pull_uint_var() # application error code
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_stop_sending_frame(
+ error_code=error_code, stream_id=stream_id
+ )
+ )
# check stream direction
self._assert_stream_can_send(frame_type, stream_id)
self._get_or_create_stream(frame_type, stream_id)
===========changed ref 3===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_path_challenge_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a PATH_CHALLENGE frame.
"""
data = buf.pull_bytes(8)
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_path_challenge_frame(data=data)
+ )
+
context.network_path.remote_challenge = data
===========changed ref 4===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_data_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a DATA_BLOCKED frame.
"""
+ limit = buf.pull_uint_var()
- buf.pull_uint_var() # limit
===========changed ref 5===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_path_response_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a PATH_RESPONSE frame.
"""
data = buf.pull_bytes(8)
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_path_response_frame(data=data)
+ )
+
if data != context.network_path.local_challenge:
raise QuicConnectionError(
error_code=QuicErrorCode.PROTOCOL_VIOLATION,
frame_type=frame_type,
reason_phrase="Response does not match challenge",
)
self._logger.info(
"Network path %s validated by challenge", context.network_path.addr
)
context.network_path.is_validated = True
===========changed ref 6===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_retire_connection_id_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a RETIRE_CONNECTION_ID frame.
"""
sequence_number = buf.pull_uint_var()
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_retire_connection_id_frame(sequence_number)
+ )
# find the connection ID by sequence number
for index, connection_id in enumerate(self._host_cids):
if connection_id.sequence_number == sequence_number:
if connection_id.cid == context.host_cid:
raise QuicConnectionError(
error_code=QuicErrorCode.PROTOCOL_VIOLATION,
frame_type=frame_type,
reason_phrase="Cannot retire current connection ID",
)
del self._host_cids[index]
self._events.append(
events.ConnectionIdRetired(connection_id=connection_id.cid)
)
break
# issue a new connection ID
self._replenish_connection_ids()
===========changed ref 7===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_reset_stream_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a RESET_STREAM frame.
"""
stream_id = buf.pull_uint_var()
error_code = buf.pull_uint_var()
final_size = buf.pull_uint_var()
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_reset_stream_frame(
+ error_code=error_code, final_size=final_size, stream_id=stream_id
+ )
+ )
# check stream direction
self._assert_stream_can_receive(frame_type, stream_id)
self._logger.info(
"Stream %d reset by peer (error code %d, final size %d)",
stream_id,
error_code,
final_size,
)
# stream = self._get_or_create_stream(frame_type, stream_id)
self._events.append(events.StreamReset(stream_id=stream_id))
|
aioquic.quic.connection/QuicConnection._write_application
|
Modified
|
aiortc~aioquic
|
5df513ec4d4581d072fb2b3d09d4f23c5a88a1b4
|
[qlog] log more frames
|
<35>:<add> # log frame
<add> if self._quic_logger is not None:
<add> builder._packet.quic_logger_frames.append(
<add> self._quic_logger.encode_path_challenge_frame(
<add> data=network_path.local_challenge
<add> )
<add> )
<add>
<37>:<add> challenge = network_path.remote_challenge
<38>:<add> buf.push_bytes(challenge)
<del> buf.push
|
# module: aioquic.quic.connection
class QuicConnection:
def _write_application(
self, builder: QuicPacketBuilder, network_path: QuicNetworkPath, now: float
) -> None:
<0> crypto_stream: Optional[QuicStream] = None
<1> if self._cryptos[tls.Epoch.ONE_RTT].send.is_valid():
<2> crypto = self._cryptos[tls.Epoch.ONE_RTT]
<3> crypto_stream = self._crypto_streams[tls.Epoch.ONE_RTT]
<4> packet_type = PACKET_TYPE_ONE_RTT
<5> elif self._cryptos[tls.Epoch.ZERO_RTT].send.is_valid():
<6> crypto = self._cryptos[tls.Epoch.ZERO_RTT]
<7> packet_type = PACKET_TYPE_ZERO_RTT
<8> else:
<9> return
<10> space = self._spaces[tls.Epoch.ONE_RTT]
<11>
<12> buf = builder.buffer
<13>
<14> while True:
<15> # write header
<16> builder.start_packet(packet_type, crypto)
<17>
<18> if self._handshake_complete:
<19> # ACK
<20> if space.ack_at is not None and space.ack_at <= now:
<21> self._write_ack_frame(builder=builder, space=space)
<22>
<23> # PATH CHALLENGE
<24> if (
<25> not network_path.is_validated
<26> and network_path.local_challenge is None
<27> ):
<28> self._logger.info(
<29> "Network path %s sending challenge", network_path.addr
<30> )
<31> network_path.local_challenge = os.urandom(8)
<32> builder.start_frame(QuicFrameType.PATH_CHALLENGE)
<33> buf.push_bytes(network_path.local_challenge)
<34>
<35> # PATH RESPONSE
<36> if network_path.remote_challenge is not None:
<37> builder.start_frame(QuicFrameType.PATH_RESPONSE)
<38> buf.push</s>
|
===========below chunk 0===========
# module: aioquic.quic.connection
class QuicConnection:
def _write_application(
self, builder: QuicPacketBuilder, network_path: QuicNetworkPath, now: float
) -> None:
# offset: 1
network_path.remote_challenge = None
# NEW_CONNECTION_ID
for connection_id in self._host_cids:
if not connection_id.was_sent:
builder.start_frame(
QuicFrameType.NEW_CONNECTION_ID,
self._on_new_connection_id_delivery,
(connection_id,),
)
push_new_connection_id_frame(
buf,
connection_id.sequence_number,
0, # FIXME: retire_prior_to
connection_id.cid,
connection_id.stateless_reset_token,
)
connection_id.was_sent = True
self._events.append(
events.ConnectionIdIssued(connection_id=connection_id.cid)
)
# RETIRE_CONNECTION_ID
while self._retire_connection_ids:
sequence_number = self._retire_connection_ids.pop(0)
builder.start_frame(
QuicFrameType.RETIRE_CONNECTION_ID,
self._on_retire_connection_id_delivery,
(sequence_number,),
)
buf.push_uint_var(sequence_number)
# STREAMS_BLOCKED
if self._streams_blocked_pending:
if self._streams_blocked_bidi:
builder.start_frame(QuicFrameType.STREAMS_BLOCKED_BIDI)
buf.push_uint_var(self._remote_max_streams_bidi)
if self._streams_blocked_uni:
builder.start_frame(QuicFrameType.STREAMS_BLOCKED_UNI)
buf.push_uint_var(self._remote_max_streams_uni)
self._streams_blocked_pending = False
# connection-level limits
</s>
===========below chunk 1===========
# module: aioquic.quic.connection
class QuicConnection:
def _write_application(
self, builder: QuicPacketBuilder, network_path: QuicNetworkPath, now: float
) -> None:
# offset: 2
<s>remote_max_streams_uni)
self._streams_blocked_pending = False
# connection-level limits
self._write_connection_limits(builder=builder, space=space)
# stream-level limits
for stream in self._streams.values():
self._write_stream_limits(builder=builder, space=space, stream=stream)
# PING (user-request)
if self._ping_pending:
self._logger.info("Sending PING in packet %d", builder.packet_number)
self._write_ping_frame(builder, self._ping_pending)
self._ping_pending.clear()
# PING (probe)
if self._probe_pending:
self._logger.info("Sending probe")
self._write_ping_frame(builder)
self._probe_pending = False
# CRYPTO
if crypto_stream is not None and not crypto_stream.send_buffer_is_empty:
self._write_crypto_frame(
builder=builder, space=space, stream=crypto_stream
)
for stream in self._streams.values():
# STREAM
if not stream.is_blocked and not stream.send_buffer_is_empty:
self._remote_max_data_used += self._write_stream_frame(
builder=builder,
space=space,
stream=stream,
max_offset=min(
stream._send_highest
+ self._remote_max_data
- self._remote_max_data_used,
stream.max_stream_data_remote,
),
)
if not builder.end_packet():
break
===========unchanged ref 0===========
at: aioquic._buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic._buffer.Buffer
push_bytes(value: bytes) -> None
at: aioquic.quic.connection
SECRETS_LABELS = [
[
None,
"QUIC_CLIENT_EARLY_TRAFFIC_SECRET",
"QUIC_CLIENT_HANDSHAKE_TRAFFIC_SECRET",
"QUIC_CLIENT_TRAFFIC_SECRET_0",
],
[
None,
None,
"QUIC_SERVER_HANDSHAKE_TRAFFIC_SECRET",
"QUIC_SERVER_TRAFFIC_SECRET_0",
],
]
stream_is_client_initiated(stream_id: int) -> bool
stream_is_unidirectional(stream_id: int) -> bool
QuicConnectionState()
QuicNetworkPath(addr: NetworkAddress, bytes_received: int=0, bytes_sent: int=0, is_validated: bool=False, local_challenge: Optional[bytes]=None, remote_challenge: Optional[bytes]=None)
at: aioquic.quic.connection.QuicConnection
_write_ack_frame(builder: QuicPacketBuilder, space: QuicPacketSpace)
at: aioquic.quic.connection.QuicConnection.__init__
self._quic_logger = configuration.quic_logger
self._configuration = configuration
self._is_client = configuration.is_client
self._cryptos: Dict[tls.Epoch, CryptoPair] = {}
self._crypto_streams: Dict[tls.Epoch, QuicStream] = {}
self._handshake_complete = False
self._local_ack_delay_exponent = 3
self._local_active_connection_id_limit = 8
self._local_max_data = MAX_DATA_WINDOW
===========unchanged ref 1===========
self._local_max_stream_data_bidi_local = MAX_DATA_WINDOW
self._local_max_stream_data_bidi_remote = MAX_DATA_WINDOW
self._local_max_stream_data_uni = MAX_DATA_WINDOW
self._local_max_streams_bidi = 128
self._local_max_streams_uni = 128
self._logger = QuicConnectionAdapter(
logger, {"host_cid": dump_cid(self.host_cid)}
)
self._original_connection_id = original_connection_id
self._remote_max_stream_data_bidi_remote = 0
self._remote_max_stream_data_uni = 0
self._remote_max_streams_bidi = 0
self._remote_max_streams_uni = 0
self._spaces: Dict[tls.Epoch, QuicPacketSpace] = {}
self._state = QuicConnectionState.FIRSTFLIGHT
self._streams_blocked_bidi: List[QuicStream] = []
self._streams_blocked_uni: List[QuicStream] = []
self._streams_blocked_pending = False
at: aioquic.quic.connection.QuicConnection._create_stream
self._streams_blocked_pending = True
at: aioquic.quic.connection.QuicConnection._handle_crypto_frame
self._handshake_complete = True
at: aioquic.quic.connection.QuicConnection._handle_max_streams_bidi_frame
self._remote_max_streams_bidi = max_streams
at: aioquic.quic.connection.QuicConnection._handle_max_streams_uni_frame
self._remote_max_streams_uni = max_streams
at: aioquic.quic.connection.QuicConnection._initialize
self.tls = tls.Context(is_client=self._is_client, logger=self._logger)
|
aioquic.quic.connection/QuicConnection._write_ack_frame
|
Modified
|
aiortc~aioquic
|
5df513ec4d4581d072fb2b3d09d4f23c5a88a1b4
|
[qlog] log more frames
|
<11>:<add> self._quic_logger.encode_ack_frame(ranges=space.ack_queue, delay=0.0)
<del> self._quic_logger.encode_ack_frame(space.ack_queue, 0.0)
|
# module: aioquic.quic.connection
class QuicConnection:
def _write_ack_frame(self, builder: QuicPacketBuilder, space: QuicPacketSpace):
<0> builder.start_frame(
<1> QuicFrameType.ACK,
<2> self._on_ack_delivery,
<3> (space, space.largest_received_packet),
<4> )
<5> push_ack_frame(builder.buffer, space.ack_queue, 0)
<6> space.ack_at = None
<7>
<8> # log frame
<9> if self._quic_logger is not None:
<10> builder._packet.quic_logger_frames.append(
<11> self._quic_logger.encode_ack_frame(space.ack_queue, 0.0)
<12> )
<13>
|
===========unchanged ref 0===========
at: aioquic.quic.connection.QuicConnection
_write_connection_limits(builder: QuicPacketBuilder, space: QuicPacketSpace) -> None
_write_streams_blocked_frame(builder: QuicPacketBuilder, frame_type: QuicFrameType, limit: int) -> None
at: aioquic.quic.connection.QuicConnection.__init__
self._remote_max_streams_bidi = 0
self._remote_max_streams_uni = 0
self._streams_blocked_uni: List[QuicStream] = []
self._streams_blocked_pending = False
at: aioquic.quic.connection.QuicConnection._create_stream
self._streams_blocked_pending = True
at: aioquic.quic.connection.QuicConnection._handle_max_streams_bidi_frame
self._remote_max_streams_bidi = max_streams
at: aioquic.quic.connection.QuicConnection._handle_max_streams_uni_frame
self._remote_max_streams_uni = max_streams
at: aioquic.quic.connection.QuicConnection._unblock_streams
self._streams_blocked_pending = False
at: aioquic.quic.connection.QuicConnection._write_application
space = self._spaces[tls.Epoch.ONE_RTT]
at: aioquic.quic.packet
QuicFrameType(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
QuicFrameType(x: Union[str, bytes, bytearray], base: int)
===========changed ref 0===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_streams_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a STREAMS_BLOCKED frame.
"""
+ limit = buf.pull_uint_var()
- buf.pull_uint_var() # limit
===========changed ref 1===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_stream_data_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a STREAM_DATA_BLOCKED frame.
"""
stream_id = buf.pull_uint_var()
+ limit = buf.pull_uint_var()
- buf.pull_uint_var() # limit
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_stream_data_blocked_frame(
+ limit=limit, stream_id=stream_id
+ )
+ )
# check stream direction
self._assert_stream_can_receive(frame_type, stream_id)
self._get_or_create_stream(frame_type, stream_id)
===========changed ref 2===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_new_token_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a NEW_TOKEN frame.
"""
+ token = pull_new_token_frame(buf)
- pull_new_token_frame(buf)
===========changed ref 3===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_stop_sending_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a STOP_SENDING frame.
"""
stream_id = buf.pull_uint_var()
+ error_code = buf.pull_uint_var() # application error code
- buf.pull_uint_var() # application error code
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_stop_sending_frame(
+ error_code=error_code, stream_id=stream_id
+ )
+ )
# check stream direction
self._assert_stream_can_send(frame_type, stream_id)
self._get_or_create_stream(frame_type, stream_id)
===========changed ref 4===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_path_challenge_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a PATH_CHALLENGE frame.
"""
data = buf.pull_bytes(8)
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_path_challenge_frame(data=data)
+ )
+
context.network_path.remote_challenge = data
===========changed ref 5===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_data_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a DATA_BLOCKED frame.
"""
+ limit = buf.pull_uint_var()
- buf.pull_uint_var() # limit
===========changed ref 6===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_path_response_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a PATH_RESPONSE frame.
"""
data = buf.pull_bytes(8)
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_path_response_frame(data=data)
+ )
+
if data != context.network_path.local_challenge:
raise QuicConnectionError(
error_code=QuicErrorCode.PROTOCOL_VIOLATION,
frame_type=frame_type,
reason_phrase="Response does not match challenge",
)
self._logger.info(
"Network path %s validated by challenge", context.network_path.addr
)
context.network_path.is_validated = True
===========changed ref 7===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_retire_connection_id_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a RETIRE_CONNECTION_ID frame.
"""
sequence_number = buf.pull_uint_var()
+
+ # log frame
+ if self._quic_logger is not None:
+ context.quic_logger_frames.append(
+ self._quic_logger.encode_retire_connection_id_frame(sequence_number)
+ )
# find the connection ID by sequence number
for index, connection_id in enumerate(self._host_cids):
if connection_id.sequence_number == sequence_number:
if connection_id.cid == context.host_cid:
raise QuicConnectionError(
error_code=QuicErrorCode.PROTOCOL_VIOLATION,
frame_type=frame_type,
reason_phrase="Cannot retire current connection ID",
)
del self._host_cids[index]
self._events.append(
events.ConnectionIdRetired(connection_id=connection_id.cid)
)
break
# issue a new connection ID
self._replenish_connection_ids()
|
tests.test_packet/FrameTest.test_new_connection_id
|
Modified
|
aiortc~aioquic
|
5df513ec4d4581d072fb2b3d09d4f23c5a88a1b4
|
[qlog] log more frames
|
<9>:<add> QuicNewConnectionIdFrame(
<add> sequence_number=2,
<add> retire_prior_to=0,
<add> connection_id=binascii.unhexlify("7813f3d9e45e0cacbb491b4b66b039f204"),
<add> stateless_reset_token=binascii.unhexlify(
<add> "06f68fede38ec4c31aba8ab1245244e8"
<del> (
<10>:<add> ),
<del> 2,
<11>:<del> 0,
<12>:<del> binascii.unhexlify("7813f3d9e45e0cacbb491b4b66b039f204"),
<13>:<del> binascii.unhexlify("06f68fede38ec4c31aba8ab1245244e8"),
<19>:<add> packet.push_new_connection_id_frame(buf, frame)
<del> packet.push_new_connection_id_frame(buf, *frame)
|
# module: tests.test_packet
class FrameTest(TestCase):
def test_new_connection_id(self):
<0> data = binascii.unhexlify(
<1> "0200117813f3d9e45e0cacbb491b4b66b039f20406f68fede38ec4c31aba8ab1245244e8"
<2> )
<3>
<4> # parse
<5> buf = Buffer(data=data)
<6> frame = packet.pull_new_connection_id_frame(buf)
<7> self.assertEqual(
<8> frame,
<9> (
<10> 2,
<11> 0,
<12> binascii.unhexlify("7813f3d9e45e0cacbb491b4b66b039f204"),
<13> binascii.unhexlify("06f68fede38ec4c31aba8ab1245244e8"),
<14> ),
<15> )
<16>
<17> # serialize
<18> buf = Buffer(capacity=len(data))
<19> packet.push_new_connection_id_frame(buf, *frame)
<20> self.assertEqual(buf.data, data)
<21>
|
===========unchanged ref 0===========
at: aioquic._buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic.quic.packet
QuicNewConnectionIdFrame(sequence_number: int, retire_prior_to: int, connection_id: bytes, stateless_reset_token: bytes)
pull_new_connection_id_frame(buf: Buffer) -> QuicNewConnectionIdFrame
at: aioquic.quic.packet.QuicNewConnectionIdFrame
sequence_number: int
retire_prior_to: int
connection_id: bytes
stateless_reset_token: bytes
at: binascii
unhexlify(hexstr: _Ascii, /) -> bytes
at: unittest.case.TestCase
failureException: Type[BaseException]
longMessage: bool
maxDiff: Optional[int]
_testMethodName: str
_testMethodDoc: str
assertEqual(first: Any, second: Any, msg: Any=...) -> None
===========changed ref 0===========
# module: aioquic.quic.packet
+ @dataclass
+ class QuicNewConnectionIdFrame:
+ sequence_number: int
+ retire_prior_to: int
+ connection_id: bytes
+ stateless_reset_token: bytes
+
===========changed ref 1===========
# module: aioquic.quic.packet
+ def pull_new_connection_id_frame(buf: Buffer) -> QuicNewConnectionIdFrame:
- def pull_new_connection_id_frame(buf: Buffer) -> Tuple[int, int, bytes, bytes]:
sequence_number = buf.pull_uint_var()
retire_prior_to = buf.pull_uint_var()
length = buf.pull_uint8()
connection_id = buf.pull_bytes(length)
stateless_reset_token = buf.pull_bytes(16)
+ return QuicNewConnectionIdFrame(
+ sequence_number=sequence_number,
+ retire_prior_to=retire_prior_to,
+ connection_id=connection_id,
+ stateless_reset_token=stateless_reset_token,
+ )
- return (sequence_number, retire_prior_to, connection_id, stateless_reset_token)
===========changed ref 2===========
# module: aioquic.quic.logger
+ def hexdump(data: bytes) -> str:
+ return binascii.hexlify(data).decode("ascii")
+
===========changed ref 3===========
# module: aioquic.quic.logger
class QuicLogger:
+ def encode_max_data_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "MAX_DATA", "maximum": str(maximum)}
+
===========changed ref 4===========
# module: aioquic.quic.logger
class QuicLogger:
+ def encode_max_streams_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "MAX_STREAMS", "maximum": str(maximum)}
+
===========changed ref 5===========
# module: aioquic.quic.logger
class QuicLogger:
+ def encode_data_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "DATA_BLOCKED", "limit": str(limit)}
+
===========changed ref 6===========
# module: aioquic.quic.logger
class QuicLogger:
+ def encode_streams_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "STREAMS_BLOCKED", "limit": str(limit)}
+
===========changed ref 7===========
# module: aioquic.quic.logger
class QuicLogger:
+ def encode_path_response_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "PATH_RESPONSE"}
+
===========changed ref 8===========
# module: aioquic.quic.logger
class QuicLogger:
+ def encode_path_challenge_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "PATH_CHALLENGE"}
+
===========changed ref 9===========
# module: aioquic.quic.logger
class QuicLogger:
+ def encode_retire_connection_id_frame(self, sequence_number: int) -> Dict:
+ return {
+ "frame_type": "RETIRE_CONNECTION_ID",
+ "sequence_number": str(sequence_number),
+ }
+
===========changed ref 10===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_new_token_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a NEW_TOKEN frame.
"""
+ token = pull_new_token_frame(buf)
- pull_new_token_frame(buf)
===========changed ref 11===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_data_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a DATA_BLOCKED frame.
"""
+ limit = buf.pull_uint_var()
- buf.pull_uint_var() # limit
===========changed ref 12===========
# module: aioquic.quic.logger
class QuicLogger:
+ def encode_new_token_frame(self, token: bytes) -> Dict:
+ return {
+ "frame_type": "NEW_TOKEN",
+ "length": str(len(token)),
+ "token": hexdump(token),
+ }
+
===========changed ref 13===========
# module: aioquic.quic.logger
class QuicLogger:
+ def encode_max_stream_data_frame(self, maximum: int, stream_id: int) -> Dict:
+ return {
+ "frame_type": "MAX_STREAM_DATA",
+ "id": str(stream_id),
+ "maximum": str(maximum),
+ }
+
===========changed ref 14===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_streams_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a STREAMS_BLOCKED frame.
"""
+ limit = buf.pull_uint_var()
- buf.pull_uint_var() # limit
===========changed ref 15===========
# module: aioquic.quic.logger
class QuicLogger:
+ def encode_stop_sending_frame(self, error_code: int, stream_id: int) -> Dict:
+ return {
+ "frame_type": "STOP_SENDING",
+ "id": str(stream_id),
+ "error_code": error_code,
+ }
+
===========changed ref 16===========
# module: aioquic.quic.logger
class QuicLogger:
+ def encode_reset_stream_frame(
+ self, error_code: int, final_size: int, stream_id: int
+ ) -> Dict:
+ return {
+ "error_code": error_code,
+ "final_size": str(final_size),
+ "frame_type": "RESET_STREAM",
+ }
+
===========changed ref 17===========
# module: aioquic.quic.logger
class QuicLogger:
+ def encode_stream_data_blocked_frame(self, limit: int, stream_id: int) -> Dict:
+ return {
+ "frame_type": "STREAM_DATA_BLOCKED",
+ "limit": str(limit),
+ "stream_id": str(stream_id),
+ }
+
===========changed ref 18===========
# module: aioquic.quic.connection
class QuicConnection:
+ def _write_streams_blocked_frame(
+ self, builder: QuicPacketBuilder, frame_type: QuicFrameType, limit: int
+ ) -> None:
+ builder.start_frame(frame_type)
+ builder.buffer.push_uint_var(limit)
+
+ # log frame
+ if self._quic_logger is not None:
+ builder._packet.quic_logger_frames.append(
+ self._quic_logger.encode_streams_blocked_frame(limit=limit)
+ )
+
|
tests.test_connection/create_standalone_client
|
Modified
|
aiortc~aioquic
|
6eaf7e7e217700c371496d329b365621847ae3ed
|
[tests] enable QuicLogger to cover logging cases
|
<0>:<add> client = QuicConnection(
<add> configuration=QuicConfiguration(is_client=True, quic_logger=QuicLogger())
<add> )
<del> client = QuicConnection(configuration=QuicConfiguration(is_client=True))
|
# module: tests.test_connection
def create_standalone_client(self):
<0> client = QuicConnection(configuration=QuicConfiguration(is_client=True))
<1> client._ack_delay = 0
<2>
<3> # kick-off handshake
<4> client.connect(SERVER_ADDR, now=time.time())
<5> self.assertEqual(drop(client), 1)
<6>
<7> return client
<8>
|
===========unchanged ref 0===========
at: aioquic.quic.configuration
QuicConfiguration(alpn_protocols: Optional[List[str]]=None, certificate: Any=None, idle_timeout: float=60.0, is_client: bool=True, private_key: Any=None, quic_logger: Optional[QuicLogger]=None, secrets_log_file: TextIO=None, server_name: Optional[str]=None, session_ticket: Optional[SessionTicket]=None, supported_versions: List[int]=field(
default_factory=lambda: [QuicProtocolVersion.DRAFT_22]
))
at: aioquic.quic.configuration.QuicConfiguration
alpn_protocols: Optional[List[str]] = None
certificate: Any = None
idle_timeout: float = 60.0
is_client: bool = True
private_key: Any = None
quic_logger: Optional[QuicLogger] = None
secrets_log_file: TextIO = None
server_name: Optional[str] = None
session_ticket: Optional[SessionTicket] = None
supported_versions: List[int] = field(
default_factory=lambda: [QuicProtocolVersion.DRAFT_22]
)
at: aioquic.quic.connection
QuicConnection(*, configuration: QuicConfiguration, original_connection_id: Optional[bytes]=None, session_ticket_fetcher: Optional[tls.SessionTicketFetcher]=None, session_ticket_handler: Optional[tls.SessionTicketHandler]=None)
at: aioquic.quic.connection.QuicConnection
connect(addr: NetworkAddress, now: float) -> None
at: aioquic.quic.connection.QuicConnection.__init__
self._ack_delay = K_GRANULARITY
at: aioquic.quic.logger
QuicLogger()
at: tests.test_connection
SERVER_ADDR = ("2.3.4.5", 4433)
drop(sender)
at: time
time() -> float
===========unchanged ref 1===========
at: unittest.case.TestCase
failureException: Type[BaseException]
longMessage: bool
maxDiff: Optional[int]
_testMethodName: str
_testMethodDoc: str
assertEqual(first: Any, second: Any, msg: Any=...) -> None
|
tests.test_connection/client_and_server
|
Modified
|
aiortc~aioquic
|
6eaf7e7e217700c371496d329b365621847ae3ed
|
[tests] enable QuicLogger to cover logging cases
|
<1>:<add> configuration=QuicConfiguration(
<add> is_client=True, quic_logger=QuicLogger(), **client_options
<add> ),
<del> configuration=QuicConfiguration(is_client=True, **client_options),
<12>:<add> quic_logger=QuicLogger(),
|
# module: tests.test_connection
@contextlib.contextmanager
def client_and_server(
client_kwargs={},
client_options={},
client_patch=lambda x: None,
handshake=True,
server_kwargs={},
server_options={},
server_patch=lambda x: None,
transport_options={},
):
<0> client = QuicConnection(
<1> configuration=QuicConfiguration(is_client=True, **client_options),
<2> **client_kwargs
<3> )
<4> client._ack_delay = 0
<5> client_patch(client)
<6>
<7> server = QuicConnection(
<8> configuration=QuicConfiguration(
<9> is_client=False,
<10> certificate=SERVER_CERTIFICATE,
<11> private_key=SERVER_PRIVATE_KEY,
<12> **server_options
<13> ),
<14> **server_kwargs
<15> )
<16> server._ack_delay = 0
<17> server_patch(server)
<18>
<19> # perform handshake
<20> if handshake:
<21> client.connect(SERVER_ADDR, now=time.time())
<22> for i in range(3):
<23> roundtrip(client, server)
<24>
<25> yield client, server
<26>
<27> # close
<28> client.close()
<29> server.close()
<30>
|
===========unchanged ref 0===========
at: aioquic.quic.configuration
QuicConfiguration(alpn_protocols: Optional[List[str]]=None, certificate: Any=None, idle_timeout: float=60.0, is_client: bool=True, private_key: Any=None, quic_logger: Optional[QuicLogger]=None, secrets_log_file: TextIO=None, server_name: Optional[str]=None, session_ticket: Optional[SessionTicket]=None, supported_versions: List[int]=field(
default_factory=lambda: [QuicProtocolVersion.DRAFT_22]
))
at: aioquic.quic.connection
QuicConnection(*, configuration: QuicConfiguration, original_connection_id: Optional[bytes]=None, session_ticket_fetcher: Optional[tls.SessionTicketFetcher]=None, session_ticket_handler: Optional[tls.SessionTicketHandler]=None)
at: aioquic.quic.connection.QuicConnection
connect(addr: NetworkAddress, now: float) -> None
at: aioquic.quic.connection.QuicConnection.__init__
self._ack_delay = K_GRANULARITY
at: aioquic.quic.logger
QuicLogger()
at: contextlib
contextmanager(func: Callable[..., Iterator[_T]]) -> Callable[..., _GeneratorContextManager[_T]]
at: tests.test_connection
SERVER_ADDR = ("2.3.4.5", 4433)
roundtrip(sender, receiver)
at: tests.utils
SERVER_CERTIFICATE = x509.load_pem_x509_certificate(
load("ssl_cert.pem"), backend=default_backend()
)
SERVER_PRIVATE_KEY = serialization.load_pem_private_key(
load("ssl_key.pem"), password=None, backend=default_backend()
)
at: time
time() -> float
===========changed ref 0===========
# module: tests.test_connection
def create_standalone_client(self):
+ client = QuicConnection(
+ configuration=QuicConfiguration(is_client=True, quic_logger=QuicLogger())
+ )
- client = QuicConnection(configuration=QuicConfiguration(is_client=True))
client._ack_delay = 0
# kick-off handshake
client.connect(SERVER_ADDR, now=time.time())
self.assertEqual(drop(client), 1)
return client
|
aioquic.quic.logger/QuicLogger.encode_ack_frame
|
Modified
|
aiortc~aioquic
|
f89f264ca7ff9bf69a5ec2c3550bb0ffa67db2da
|
[qlog] switch to draft-01
|
<3>:<add> "frame_type": "ack",
<del> "frame_type": "ACK",
|
# module: aioquic.quic.logger
class QuicLogger:
def encode_ack_frame(self, ranges: RangeSet, delay: float) -> Dict:
<0> return {
<1> "ack_delay": str(int(delay * 1000)), # convert to ms
<2> "acked_ranges": [[str(x.start), str(x.stop - 1)] for x in ranges],
<3> "frame_type": "ACK",
<4> }
<5>
|
===========unchanged ref 0===========
at: aioquic.quic.rangeset
RangeSet(ranges: Iterable[range]=[])
at: typing
Dict = _alias(dict, 2, inst=False, name='Dict')
===========changed ref 0===========
# module: aioquic.quic.logger
PACKET_TYPE_NAMES = {
+ PACKET_TYPE_INITIAL: "initial",
- PACKET_TYPE_INITIAL: "INITIAL",
+ PACKET_TYPE_HANDSHAKE: "handshake",
- PACKET_TYPE_HANDSHAKE: "HANDSHAKE",
PACKET_TYPE_ZERO_RTT: "0RTT",
PACKET_TYPE_ONE_RTT: "1RTT",
+ PACKET_TYPE_RETRY: "retry",
- PACKET_TYPE_RETRY: "RETRY",
}
|
aioquic.quic.logger/QuicLogger.encode_connection_close_frame
|
Modified
|
aiortc~aioquic
|
f89f264ca7ff9bf69a5ec2c3550bb0ffa67db2da
|
[qlog] switch to draft-01
|
<3>:<add> "frame_type": "connection_close",
<del> "frame_type": "CONNECTION_CLOSE",
|
# module: aioquic.quic.logger
class QuicLogger:
def encode_connection_close_frame(
self, error_code: int, frame_type: Optional[int], reason_phrase: str
) -> Dict:
<0> attrs = {
<1> "error_code": error_code,
<2> "error_space": "application" if frame_type is None else "transport",
<3> "frame_type": "CONNECTION_CLOSE",
<4> "raw_error_code": error_code,
<5> "reason": reason_phrase,
<6> }
<7> if frame_type is not None:
<8> attrs["trigger_frame_type"] = frame_type
<9>
<10> return attrs
<11>
|
===========unchanged ref 0===========
at: typing
Dict = _alias(dict, 2, inst=False, name='Dict')
===========changed ref 0===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_ack_frame(self, ranges: RangeSet, delay: float) -> Dict:
return {
"ack_delay": str(int(delay * 1000)), # convert to ms
"acked_ranges": [[str(x.start), str(x.stop - 1)] for x in ranges],
+ "frame_type": "ack",
- "frame_type": "ACK",
}
===========changed ref 1===========
# module: aioquic.quic.logger
PACKET_TYPE_NAMES = {
+ PACKET_TYPE_INITIAL: "initial",
- PACKET_TYPE_INITIAL: "INITIAL",
+ PACKET_TYPE_HANDSHAKE: "handshake",
- PACKET_TYPE_HANDSHAKE: "HANDSHAKE",
PACKET_TYPE_ZERO_RTT: "0RTT",
PACKET_TYPE_ONE_RTT: "1RTT",
+ PACKET_TYPE_RETRY: "retry",
- PACKET_TYPE_RETRY: "RETRY",
}
|
aioquic.quic.logger/QuicLogger.encode_crypto_frame
|
Modified
|
aiortc~aioquic
|
f89f264ca7ff9bf69a5ec2c3550bb0ffa67db2da
|
[qlog] switch to draft-01
|
<2>:<add> "frame_type": "crypto",
<del> "frame_type": "CRYPTO",
|
# module: aioquic.quic.logger
class QuicLogger:
def encode_crypto_frame(self, frame: QuicStreamFrame) -> Dict:
<0> return {
<1> "fin": frame.fin,
<2> "frame_type": "CRYPTO",
<3> "length": str(len(frame.data)),
<4> "offset": str(frame.offset),
<5> }
<6>
|
===========unchanged ref 0===========
at: aioquic.quic.packet
QuicStreamFrame(data: bytes=b"", fin: bool=False, offset: int=0)
at: aioquic.quic.packet.QuicStreamFrame
data: bytes = b""
fin: bool = False
offset: int = 0
at: typing
Dict = _alias(dict, 2, inst=False, name='Dict')
===========changed ref 0===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_ack_frame(self, ranges: RangeSet, delay: float) -> Dict:
return {
"ack_delay": str(int(delay * 1000)), # convert to ms
"acked_ranges": [[str(x.start), str(x.stop - 1)] for x in ranges],
+ "frame_type": "ack",
- "frame_type": "ACK",
}
===========changed ref 1===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_connection_close_frame(
self, error_code: int, frame_type: Optional[int], reason_phrase: str
) -> Dict:
attrs = {
"error_code": error_code,
"error_space": "application" if frame_type is None else "transport",
+ "frame_type": "connection_close",
- "frame_type": "CONNECTION_CLOSE",
"raw_error_code": error_code,
"reason": reason_phrase,
}
if frame_type is not None:
attrs["trigger_frame_type"] = frame_type
return attrs
===========changed ref 2===========
# module: aioquic.quic.logger
PACKET_TYPE_NAMES = {
+ PACKET_TYPE_INITIAL: "initial",
- PACKET_TYPE_INITIAL: "INITIAL",
+ PACKET_TYPE_HANDSHAKE: "handshake",
- PACKET_TYPE_HANDSHAKE: "HANDSHAKE",
PACKET_TYPE_ZERO_RTT: "0RTT",
PACKET_TYPE_ONE_RTT: "1RTT",
+ PACKET_TYPE_RETRY: "retry",
- PACKET_TYPE_RETRY: "RETRY",
}
|
aioquic.quic.logger/QuicLogger.encode_data_blocked_frame
|
Modified
|
aiortc~aioquic
|
f89f264ca7ff9bf69a5ec2c3550bb0ffa67db2da
|
[qlog] switch to draft-01
|
<0>:<add> return {"frame_type": "data_blocked", "limit": str(limit)}
<del> return {"frame_type": "DATA_BLOCKED", "limit": str(limit)}
|
# module: aioquic.quic.logger
class QuicLogger:
def encode_data_blocked_frame(self, limit: int) -> Dict:
<0> return {"frame_type": "DATA_BLOCKED", "limit": str(limit)}
<1>
|
===========unchanged ref 0===========
at: typing
Dict = _alias(dict, 2, inst=False, name='Dict')
===========changed ref 0===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_crypto_frame(self, frame: QuicStreamFrame) -> Dict:
return {
"fin": frame.fin,
+ "frame_type": "crypto",
- "frame_type": "CRYPTO",
"length": str(len(frame.data)),
"offset": str(frame.offset),
}
===========changed ref 1===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_ack_frame(self, ranges: RangeSet, delay: float) -> Dict:
return {
"ack_delay": str(int(delay * 1000)), # convert to ms
"acked_ranges": [[str(x.start), str(x.stop - 1)] for x in ranges],
+ "frame_type": "ack",
- "frame_type": "ACK",
}
===========changed ref 2===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_connection_close_frame(
self, error_code: int, frame_type: Optional[int], reason_phrase: str
) -> Dict:
attrs = {
"error_code": error_code,
"error_space": "application" if frame_type is None else "transport",
+ "frame_type": "connection_close",
- "frame_type": "CONNECTION_CLOSE",
"raw_error_code": error_code,
"reason": reason_phrase,
}
if frame_type is not None:
attrs["trigger_frame_type"] = frame_type
return attrs
===========changed ref 3===========
# module: aioquic.quic.logger
PACKET_TYPE_NAMES = {
+ PACKET_TYPE_INITIAL: "initial",
- PACKET_TYPE_INITIAL: "INITIAL",
+ PACKET_TYPE_HANDSHAKE: "handshake",
- PACKET_TYPE_HANDSHAKE: "HANDSHAKE",
PACKET_TYPE_ZERO_RTT: "0RTT",
PACKET_TYPE_ONE_RTT: "1RTT",
+ PACKET_TYPE_RETRY: "retry",
- PACKET_TYPE_RETRY: "RETRY",
}
|
aioquic.quic.logger/QuicLogger.encode_max_data_frame
|
Modified
|
aiortc~aioquic
|
f89f264ca7ff9bf69a5ec2c3550bb0ffa67db2da
|
[qlog] switch to draft-01
|
<0>:<add> return {"frame_type": "max_data", "maximum": str(maximum)}
<del> return {"frame_type": "MAX_DATA", "maximum": str(maximum)}
|
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_data_frame(self, maximum: int) -> Dict:
<0> return {"frame_type": "MAX_DATA", "maximum": str(maximum)}
<1>
|
===========unchanged ref 0===========
at: typing
Dict = _alias(dict, 2, inst=False, name='Dict')
===========changed ref 0===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_data_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "data_blocked", "limit": str(limit)}
- return {"frame_type": "DATA_BLOCKED", "limit": str(limit)}
===========changed ref 1===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_crypto_frame(self, frame: QuicStreamFrame) -> Dict:
return {
"fin": frame.fin,
+ "frame_type": "crypto",
- "frame_type": "CRYPTO",
"length": str(len(frame.data)),
"offset": str(frame.offset),
}
===========changed ref 2===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_ack_frame(self, ranges: RangeSet, delay: float) -> Dict:
return {
"ack_delay": str(int(delay * 1000)), # convert to ms
"acked_ranges": [[str(x.start), str(x.stop - 1)] for x in ranges],
+ "frame_type": "ack",
- "frame_type": "ACK",
}
===========changed ref 3===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_connection_close_frame(
self, error_code: int, frame_type: Optional[int], reason_phrase: str
) -> Dict:
attrs = {
"error_code": error_code,
"error_space": "application" if frame_type is None else "transport",
+ "frame_type": "connection_close",
- "frame_type": "CONNECTION_CLOSE",
"raw_error_code": error_code,
"reason": reason_phrase,
}
if frame_type is not None:
attrs["trigger_frame_type"] = frame_type
return attrs
===========changed ref 4===========
# module: aioquic.quic.logger
PACKET_TYPE_NAMES = {
+ PACKET_TYPE_INITIAL: "initial",
- PACKET_TYPE_INITIAL: "INITIAL",
+ PACKET_TYPE_HANDSHAKE: "handshake",
- PACKET_TYPE_HANDSHAKE: "HANDSHAKE",
PACKET_TYPE_ZERO_RTT: "0RTT",
PACKET_TYPE_ONE_RTT: "1RTT",
+ PACKET_TYPE_RETRY: "retry",
- PACKET_TYPE_RETRY: "RETRY",
}
|
aioquic.quic.logger/QuicLogger.encode_max_stream_data_frame
|
Modified
|
aiortc~aioquic
|
f89f264ca7ff9bf69a5ec2c3550bb0ffa67db2da
|
[qlog] switch to draft-01
|
<1>:<add> "frame_type": "max_stream_data",
<del> "frame_type": "MAX_STREAM_DATA",
|
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_stream_data_frame(self, maximum: int, stream_id: int) -> Dict:
<0> return {
<1> "frame_type": "MAX_STREAM_DATA",
<2> "id": str(stream_id),
<3> "maximum": str(maximum),
<4> }
<5>
|
===========unchanged ref 0===========
at: typing
Dict = _alias(dict, 2, inst=False, name='Dict')
===========changed ref 0===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_data_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_data", "maximum": str(maximum)}
- return {"frame_type": "MAX_DATA", "maximum": str(maximum)}
===========changed ref 1===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_data_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "data_blocked", "limit": str(limit)}
- return {"frame_type": "DATA_BLOCKED", "limit": str(limit)}
===========changed ref 2===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_crypto_frame(self, frame: QuicStreamFrame) -> Dict:
return {
"fin": frame.fin,
+ "frame_type": "crypto",
- "frame_type": "CRYPTO",
"length": str(len(frame.data)),
"offset": str(frame.offset),
}
===========changed ref 3===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_ack_frame(self, ranges: RangeSet, delay: float) -> Dict:
return {
"ack_delay": str(int(delay * 1000)), # convert to ms
"acked_ranges": [[str(x.start), str(x.stop - 1)] for x in ranges],
+ "frame_type": "ack",
- "frame_type": "ACK",
}
===========changed ref 4===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_connection_close_frame(
self, error_code: int, frame_type: Optional[int], reason_phrase: str
) -> Dict:
attrs = {
"error_code": error_code,
"error_space": "application" if frame_type is None else "transport",
+ "frame_type": "connection_close",
- "frame_type": "CONNECTION_CLOSE",
"raw_error_code": error_code,
"reason": reason_phrase,
}
if frame_type is not None:
attrs["trigger_frame_type"] = frame_type
return attrs
===========changed ref 5===========
# module: aioquic.quic.logger
PACKET_TYPE_NAMES = {
+ PACKET_TYPE_INITIAL: "initial",
- PACKET_TYPE_INITIAL: "INITIAL",
+ PACKET_TYPE_HANDSHAKE: "handshake",
- PACKET_TYPE_HANDSHAKE: "HANDSHAKE",
PACKET_TYPE_ZERO_RTT: "0RTT",
PACKET_TYPE_ONE_RTT: "1RTT",
+ PACKET_TYPE_RETRY: "retry",
- PACKET_TYPE_RETRY: "RETRY",
}
|
aioquic.quic.logger/QuicLogger.encode_max_streams_frame
|
Modified
|
aiortc~aioquic
|
f89f264ca7ff9bf69a5ec2c3550bb0ffa67db2da
|
[qlog] switch to draft-01
|
<0>:<add> return {"frame_type": "max_streams", "maximum": str(maximum)}
<del> return {"frame_type": "MAX_STREAMS", "maximum": str(maximum)}
|
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_streams_frame(self, maximum: int) -> Dict:
<0> return {"frame_type": "MAX_STREAMS", "maximum": str(maximum)}
<1>
|
===========unchanged ref 0===========
at: typing
Dict = _alias(dict, 2, inst=False, name='Dict')
===========changed ref 0===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_data_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_data", "maximum": str(maximum)}
- return {"frame_type": "MAX_DATA", "maximum": str(maximum)}
===========changed ref 1===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_data_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "data_blocked", "limit": str(limit)}
- return {"frame_type": "DATA_BLOCKED", "limit": str(limit)}
===========changed ref 2===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_stream_data_frame(self, maximum: int, stream_id: int) -> Dict:
return {
+ "frame_type": "max_stream_data",
- "frame_type": "MAX_STREAM_DATA",
"id": str(stream_id),
"maximum": str(maximum),
}
===========changed ref 3===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_crypto_frame(self, frame: QuicStreamFrame) -> Dict:
return {
"fin": frame.fin,
+ "frame_type": "crypto",
- "frame_type": "CRYPTO",
"length": str(len(frame.data)),
"offset": str(frame.offset),
}
===========changed ref 4===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_ack_frame(self, ranges: RangeSet, delay: float) -> Dict:
return {
"ack_delay": str(int(delay * 1000)), # convert to ms
"acked_ranges": [[str(x.start), str(x.stop - 1)] for x in ranges],
+ "frame_type": "ack",
- "frame_type": "ACK",
}
===========changed ref 5===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_connection_close_frame(
self, error_code: int, frame_type: Optional[int], reason_phrase: str
) -> Dict:
attrs = {
"error_code": error_code,
"error_space": "application" if frame_type is None else "transport",
+ "frame_type": "connection_close",
- "frame_type": "CONNECTION_CLOSE",
"raw_error_code": error_code,
"reason": reason_phrase,
}
if frame_type is not None:
attrs["trigger_frame_type"] = frame_type
return attrs
===========changed ref 6===========
# module: aioquic.quic.logger
PACKET_TYPE_NAMES = {
+ PACKET_TYPE_INITIAL: "initial",
- PACKET_TYPE_INITIAL: "INITIAL",
+ PACKET_TYPE_HANDSHAKE: "handshake",
- PACKET_TYPE_HANDSHAKE: "HANDSHAKE",
PACKET_TYPE_ZERO_RTT: "0RTT",
PACKET_TYPE_ONE_RTT: "1RTT",
+ PACKET_TYPE_RETRY: "retry",
- PACKET_TYPE_RETRY: "RETRY",
}
|
aioquic.quic.logger/QuicLogger.encode_new_connection_id_frame
|
Modified
|
aiortc~aioquic
|
f89f264ca7ff9bf69a5ec2c3550bb0ffa67db2da
|
[qlog] switch to draft-01
|
<2>:<add> "frame_type": "new_connection_id",
<del> "frame_type": "NEW_CONNECTION_ID",
|
# module: aioquic.quic.logger
class QuicLogger:
def encode_new_connection_id_frame(self, frame: QuicNewConnectionIdFrame) -> Dict:
<0> return {
<1> "connection_id": hexdump(frame.connection_id),
<2> "frame_type": "NEW_CONNECTION_ID",
<3> "length": len(str(frame.connection_id)),
<4> "reset_token": hexdump(frame.stateless_reset_token),
<5> "retire_prior_to": str(frame.retire_prior_to),
<6> "sequence_number": str(frame.sequence_number),
<7> }
<8>
|
===========unchanged ref 0===========
at: aioquic.quic.logger
hexdump(data: bytes) -> str
at: aioquic.quic.packet
QuicNewConnectionIdFrame(sequence_number: int, retire_prior_to: int, connection_id: bytes, stateless_reset_token: bytes)
at: aioquic.quic.packet.QuicNewConnectionIdFrame
sequence_number: int
retire_prior_to: int
connection_id: bytes
stateless_reset_token: bytes
at: typing
Dict = _alias(dict, 2, inst=False, name='Dict')
===========changed ref 0===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_streams_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_streams", "maximum": str(maximum)}
- return {"frame_type": "MAX_STREAMS", "maximum": str(maximum)}
===========changed ref 1===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_data_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_data", "maximum": str(maximum)}
- return {"frame_type": "MAX_DATA", "maximum": str(maximum)}
===========changed ref 2===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_data_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "data_blocked", "limit": str(limit)}
- return {"frame_type": "DATA_BLOCKED", "limit": str(limit)}
===========changed ref 3===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_stream_data_frame(self, maximum: int, stream_id: int) -> Dict:
return {
+ "frame_type": "max_stream_data",
- "frame_type": "MAX_STREAM_DATA",
"id": str(stream_id),
"maximum": str(maximum),
}
===========changed ref 4===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_crypto_frame(self, frame: QuicStreamFrame) -> Dict:
return {
"fin": frame.fin,
+ "frame_type": "crypto",
- "frame_type": "CRYPTO",
"length": str(len(frame.data)),
"offset": str(frame.offset),
}
===========changed ref 5===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_ack_frame(self, ranges: RangeSet, delay: float) -> Dict:
return {
"ack_delay": str(int(delay * 1000)), # convert to ms
"acked_ranges": [[str(x.start), str(x.stop - 1)] for x in ranges],
+ "frame_type": "ack",
- "frame_type": "ACK",
}
===========changed ref 6===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_connection_close_frame(
self, error_code: int, frame_type: Optional[int], reason_phrase: str
) -> Dict:
attrs = {
"error_code": error_code,
"error_space": "application" if frame_type is None else "transport",
+ "frame_type": "connection_close",
- "frame_type": "CONNECTION_CLOSE",
"raw_error_code": error_code,
"reason": reason_phrase,
}
if frame_type is not None:
attrs["trigger_frame_type"] = frame_type
return attrs
===========changed ref 7===========
# module: aioquic.quic.logger
PACKET_TYPE_NAMES = {
+ PACKET_TYPE_INITIAL: "initial",
- PACKET_TYPE_INITIAL: "INITIAL",
+ PACKET_TYPE_HANDSHAKE: "handshake",
- PACKET_TYPE_HANDSHAKE: "HANDSHAKE",
PACKET_TYPE_ZERO_RTT: "0RTT",
PACKET_TYPE_ONE_RTT: "1RTT",
+ PACKET_TYPE_RETRY: "retry",
- PACKET_TYPE_RETRY: "RETRY",
}
|
aioquic.quic.logger/QuicLogger.encode_new_token_frame
|
Modified
|
aiortc~aioquic
|
f89f264ca7ff9bf69a5ec2c3550bb0ffa67db2da
|
[qlog] switch to draft-01
|
<1>:<add> "frame_type": "new_token",
<del> "frame_type": "NEW_TOKEN",
|
# module: aioquic.quic.logger
class QuicLogger:
def encode_new_token_frame(self, token: bytes) -> Dict:
<0> return {
<1> "frame_type": "NEW_TOKEN",
<2> "length": str(len(token)),
<3> "token": hexdump(token),
<4> }
<5>
|
===========unchanged ref 0===========
at: aioquic.quic.logger
hexdump(data: bytes) -> str
at: typing
Dict = _alias(dict, 2, inst=False, name='Dict')
===========changed ref 0===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_streams_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_streams", "maximum": str(maximum)}
- return {"frame_type": "MAX_STREAMS", "maximum": str(maximum)}
===========changed ref 1===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_data_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_data", "maximum": str(maximum)}
- return {"frame_type": "MAX_DATA", "maximum": str(maximum)}
===========changed ref 2===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_data_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "data_blocked", "limit": str(limit)}
- return {"frame_type": "DATA_BLOCKED", "limit": str(limit)}
===========changed ref 3===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_stream_data_frame(self, maximum: int, stream_id: int) -> Dict:
return {
+ "frame_type": "max_stream_data",
- "frame_type": "MAX_STREAM_DATA",
"id": str(stream_id),
"maximum": str(maximum),
}
===========changed ref 4===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_crypto_frame(self, frame: QuicStreamFrame) -> Dict:
return {
"fin": frame.fin,
+ "frame_type": "crypto",
- "frame_type": "CRYPTO",
"length": str(len(frame.data)),
"offset": str(frame.offset),
}
===========changed ref 5===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_new_connection_id_frame(self, frame: QuicNewConnectionIdFrame) -> Dict:
return {
"connection_id": hexdump(frame.connection_id),
+ "frame_type": "new_connection_id",
- "frame_type": "NEW_CONNECTION_ID",
"length": len(str(frame.connection_id)),
"reset_token": hexdump(frame.stateless_reset_token),
"retire_prior_to": str(frame.retire_prior_to),
"sequence_number": str(frame.sequence_number),
}
===========changed ref 6===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_ack_frame(self, ranges: RangeSet, delay: float) -> Dict:
return {
"ack_delay": str(int(delay * 1000)), # convert to ms
"acked_ranges": [[str(x.start), str(x.stop - 1)] for x in ranges],
+ "frame_type": "ack",
- "frame_type": "ACK",
}
===========changed ref 7===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_connection_close_frame(
self, error_code: int, frame_type: Optional[int], reason_phrase: str
) -> Dict:
attrs = {
"error_code": error_code,
"error_space": "application" if frame_type is None else "transport",
+ "frame_type": "connection_close",
- "frame_type": "CONNECTION_CLOSE",
"raw_error_code": error_code,
"reason": reason_phrase,
}
if frame_type is not None:
attrs["trigger_frame_type"] = frame_type
return attrs
===========changed ref 8===========
# module: aioquic.quic.logger
PACKET_TYPE_NAMES = {
+ PACKET_TYPE_INITIAL: "initial",
- PACKET_TYPE_INITIAL: "INITIAL",
+ PACKET_TYPE_HANDSHAKE: "handshake",
- PACKET_TYPE_HANDSHAKE: "HANDSHAKE",
PACKET_TYPE_ZERO_RTT: "0RTT",
PACKET_TYPE_ONE_RTT: "1RTT",
+ PACKET_TYPE_RETRY: "retry",
- PACKET_TYPE_RETRY: "RETRY",
}
|
aioquic.quic.logger/QuicLogger.encode_padding_frame
|
Modified
|
aiortc~aioquic
|
f89f264ca7ff9bf69a5ec2c3550bb0ffa67db2da
|
[qlog] switch to draft-01
|
<0>:<add> return {"frame_type": "padding"}
<del> return {"frame_type": "PADDING"}
|
# module: aioquic.quic.logger
class QuicLogger:
def encode_padding_frame(self) -> Dict:
<0> return {"frame_type": "PADDING"}
<1>
|
===========unchanged ref 0===========
at: typing
Dict = _alias(dict, 2, inst=False, name='Dict')
===========changed ref 0===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_new_token_frame(self, token: bytes) -> Dict:
return {
+ "frame_type": "new_token",
- "frame_type": "NEW_TOKEN",
"length": str(len(token)),
"token": hexdump(token),
}
===========changed ref 1===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_streams_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_streams", "maximum": str(maximum)}
- return {"frame_type": "MAX_STREAMS", "maximum": str(maximum)}
===========changed ref 2===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_data_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_data", "maximum": str(maximum)}
- return {"frame_type": "MAX_DATA", "maximum": str(maximum)}
===========changed ref 3===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_data_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "data_blocked", "limit": str(limit)}
- return {"frame_type": "DATA_BLOCKED", "limit": str(limit)}
===========changed ref 4===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_stream_data_frame(self, maximum: int, stream_id: int) -> Dict:
return {
+ "frame_type": "max_stream_data",
- "frame_type": "MAX_STREAM_DATA",
"id": str(stream_id),
"maximum": str(maximum),
}
===========changed ref 5===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_crypto_frame(self, frame: QuicStreamFrame) -> Dict:
return {
"fin": frame.fin,
+ "frame_type": "crypto",
- "frame_type": "CRYPTO",
"length": str(len(frame.data)),
"offset": str(frame.offset),
}
===========changed ref 6===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_new_connection_id_frame(self, frame: QuicNewConnectionIdFrame) -> Dict:
return {
"connection_id": hexdump(frame.connection_id),
+ "frame_type": "new_connection_id",
- "frame_type": "NEW_CONNECTION_ID",
"length": len(str(frame.connection_id)),
"reset_token": hexdump(frame.stateless_reset_token),
"retire_prior_to": str(frame.retire_prior_to),
"sequence_number": str(frame.sequence_number),
}
===========changed ref 7===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_ack_frame(self, ranges: RangeSet, delay: float) -> Dict:
return {
"ack_delay": str(int(delay * 1000)), # convert to ms
"acked_ranges": [[str(x.start), str(x.stop - 1)] for x in ranges],
+ "frame_type": "ack",
- "frame_type": "ACK",
}
===========changed ref 8===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_connection_close_frame(
self, error_code: int, frame_type: Optional[int], reason_phrase: str
) -> Dict:
attrs = {
"error_code": error_code,
"error_space": "application" if frame_type is None else "transport",
+ "frame_type": "connection_close",
- "frame_type": "CONNECTION_CLOSE",
"raw_error_code": error_code,
"reason": reason_phrase,
}
if frame_type is not None:
attrs["trigger_frame_type"] = frame_type
return attrs
===========changed ref 9===========
# module: aioquic.quic.logger
PACKET_TYPE_NAMES = {
+ PACKET_TYPE_INITIAL: "initial",
- PACKET_TYPE_INITIAL: "INITIAL",
+ PACKET_TYPE_HANDSHAKE: "handshake",
- PACKET_TYPE_HANDSHAKE: "HANDSHAKE",
PACKET_TYPE_ZERO_RTT: "0RTT",
PACKET_TYPE_ONE_RTT: "1RTT",
+ PACKET_TYPE_RETRY: "retry",
- PACKET_TYPE_RETRY: "RETRY",
}
|
aioquic.quic.logger/QuicLogger.encode_path_challenge_frame
|
Modified
|
aiortc~aioquic
|
f89f264ca7ff9bf69a5ec2c3550bb0ffa67db2da
|
[qlog] switch to draft-01
|
<0>:<add> return {"data": hexdump(data), "frame_type": "path_challenge"}
<del> return {"data": hexdump(data), "frame_type": "PATH_CHALLENGE"}
|
# module: aioquic.quic.logger
class QuicLogger:
def encode_path_challenge_frame(self, data: bytes) -> Dict:
<0> return {"data": hexdump(data), "frame_type": "PATH_CHALLENGE"}
<1>
|
===========unchanged ref 0===========
at: aioquic.quic.logger
hexdump(data: bytes) -> str
at: typing
Dict = _alias(dict, 2, inst=False, name='Dict')
===========changed ref 0===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_padding_frame(self) -> Dict:
+ return {"frame_type": "padding"}
- return {"frame_type": "PADDING"}
===========changed ref 1===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_new_token_frame(self, token: bytes) -> Dict:
return {
+ "frame_type": "new_token",
- "frame_type": "NEW_TOKEN",
"length": str(len(token)),
"token": hexdump(token),
}
===========changed ref 2===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_streams_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_streams", "maximum": str(maximum)}
- return {"frame_type": "MAX_STREAMS", "maximum": str(maximum)}
===========changed ref 3===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_data_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_data", "maximum": str(maximum)}
- return {"frame_type": "MAX_DATA", "maximum": str(maximum)}
===========changed ref 4===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_data_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "data_blocked", "limit": str(limit)}
- return {"frame_type": "DATA_BLOCKED", "limit": str(limit)}
===========changed ref 5===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_stream_data_frame(self, maximum: int, stream_id: int) -> Dict:
return {
+ "frame_type": "max_stream_data",
- "frame_type": "MAX_STREAM_DATA",
"id": str(stream_id),
"maximum": str(maximum),
}
===========changed ref 6===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_crypto_frame(self, frame: QuicStreamFrame) -> Dict:
return {
"fin": frame.fin,
+ "frame_type": "crypto",
- "frame_type": "CRYPTO",
"length": str(len(frame.data)),
"offset": str(frame.offset),
}
===========changed ref 7===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_new_connection_id_frame(self, frame: QuicNewConnectionIdFrame) -> Dict:
return {
"connection_id": hexdump(frame.connection_id),
+ "frame_type": "new_connection_id",
- "frame_type": "NEW_CONNECTION_ID",
"length": len(str(frame.connection_id)),
"reset_token": hexdump(frame.stateless_reset_token),
"retire_prior_to": str(frame.retire_prior_to),
"sequence_number": str(frame.sequence_number),
}
===========changed ref 8===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_ack_frame(self, ranges: RangeSet, delay: float) -> Dict:
return {
"ack_delay": str(int(delay * 1000)), # convert to ms
"acked_ranges": [[str(x.start), str(x.stop - 1)] for x in ranges],
+ "frame_type": "ack",
- "frame_type": "ACK",
}
===========changed ref 9===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_connection_close_frame(
self, error_code: int, frame_type: Optional[int], reason_phrase: str
) -> Dict:
attrs = {
"error_code": error_code,
"error_space": "application" if frame_type is None else "transport",
+ "frame_type": "connection_close",
- "frame_type": "CONNECTION_CLOSE",
"raw_error_code": error_code,
"reason": reason_phrase,
}
if frame_type is not None:
attrs["trigger_frame_type"] = frame_type
return attrs
===========changed ref 10===========
# module: aioquic.quic.logger
PACKET_TYPE_NAMES = {
+ PACKET_TYPE_INITIAL: "initial",
- PACKET_TYPE_INITIAL: "INITIAL",
+ PACKET_TYPE_HANDSHAKE: "handshake",
- PACKET_TYPE_HANDSHAKE: "HANDSHAKE",
PACKET_TYPE_ZERO_RTT: "0RTT",
PACKET_TYPE_ONE_RTT: "1RTT",
+ PACKET_TYPE_RETRY: "retry",
- PACKET_TYPE_RETRY: "RETRY",
}
|
aioquic.quic.logger/QuicLogger.encode_path_response_frame
|
Modified
|
aiortc~aioquic
|
f89f264ca7ff9bf69a5ec2c3550bb0ffa67db2da
|
[qlog] switch to draft-01
|
<0>:<add> return {"data": hexdump(data), "frame_type": "path_response"}
<del> return {"data": hexdump(data), "frame_type": "PATH_RESPONSE"}
|
# module: aioquic.quic.logger
class QuicLogger:
def encode_path_response_frame(self, data: bytes) -> Dict:
<0> return {"data": hexdump(data), "frame_type": "PATH_RESPONSE"}
<1>
|
===========unchanged ref 0===========
at: aioquic.quic.logger
hexdump(data: bytes) -> str
at: typing
Dict = _alias(dict, 2, inst=False, name='Dict')
===========changed ref 0===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_padding_frame(self) -> Dict:
+ return {"frame_type": "padding"}
- return {"frame_type": "PADDING"}
===========changed ref 1===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_path_challenge_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "path_challenge"}
- return {"data": hexdump(data), "frame_type": "PATH_CHALLENGE"}
===========changed ref 2===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_new_token_frame(self, token: bytes) -> Dict:
return {
+ "frame_type": "new_token",
- "frame_type": "NEW_TOKEN",
"length": str(len(token)),
"token": hexdump(token),
}
===========changed ref 3===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_streams_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_streams", "maximum": str(maximum)}
- return {"frame_type": "MAX_STREAMS", "maximum": str(maximum)}
===========changed ref 4===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_data_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_data", "maximum": str(maximum)}
- return {"frame_type": "MAX_DATA", "maximum": str(maximum)}
===========changed ref 5===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_data_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "data_blocked", "limit": str(limit)}
- return {"frame_type": "DATA_BLOCKED", "limit": str(limit)}
===========changed ref 6===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_stream_data_frame(self, maximum: int, stream_id: int) -> Dict:
return {
+ "frame_type": "max_stream_data",
- "frame_type": "MAX_STREAM_DATA",
"id": str(stream_id),
"maximum": str(maximum),
}
===========changed ref 7===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_crypto_frame(self, frame: QuicStreamFrame) -> Dict:
return {
"fin": frame.fin,
+ "frame_type": "crypto",
- "frame_type": "CRYPTO",
"length": str(len(frame.data)),
"offset": str(frame.offset),
}
===========changed ref 8===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_new_connection_id_frame(self, frame: QuicNewConnectionIdFrame) -> Dict:
return {
"connection_id": hexdump(frame.connection_id),
+ "frame_type": "new_connection_id",
- "frame_type": "NEW_CONNECTION_ID",
"length": len(str(frame.connection_id)),
"reset_token": hexdump(frame.stateless_reset_token),
"retire_prior_to": str(frame.retire_prior_to),
"sequence_number": str(frame.sequence_number),
}
===========changed ref 9===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_ack_frame(self, ranges: RangeSet, delay: float) -> Dict:
return {
"ack_delay": str(int(delay * 1000)), # convert to ms
"acked_ranges": [[str(x.start), str(x.stop - 1)] for x in ranges],
+ "frame_type": "ack",
- "frame_type": "ACK",
}
===========changed ref 10===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_connection_close_frame(
self, error_code: int, frame_type: Optional[int], reason_phrase: str
) -> Dict:
attrs = {
"error_code": error_code,
"error_space": "application" if frame_type is None else "transport",
+ "frame_type": "connection_close",
- "frame_type": "CONNECTION_CLOSE",
"raw_error_code": error_code,
"reason": reason_phrase,
}
if frame_type is not None:
attrs["trigger_frame_type"] = frame_type
return attrs
===========changed ref 11===========
# module: aioquic.quic.logger
PACKET_TYPE_NAMES = {
+ PACKET_TYPE_INITIAL: "initial",
- PACKET_TYPE_INITIAL: "INITIAL",
+ PACKET_TYPE_HANDSHAKE: "handshake",
- PACKET_TYPE_HANDSHAKE: "HANDSHAKE",
PACKET_TYPE_ZERO_RTT: "0RTT",
PACKET_TYPE_ONE_RTT: "1RTT",
+ PACKET_TYPE_RETRY: "retry",
- PACKET_TYPE_RETRY: "RETRY",
}
|
aioquic.quic.logger/QuicLogger.encode_ping_frame
|
Modified
|
aiortc~aioquic
|
f89f264ca7ff9bf69a5ec2c3550bb0ffa67db2da
|
[qlog] switch to draft-01
|
<0>:<add> return {"frame_type": "ping"}
<del> return {"frame_type": "PING"}
|
# module: aioquic.quic.logger
class QuicLogger:
def encode_ping_frame(self) -> Dict:
<0> return {"frame_type": "PING"}
<1>
|
===========unchanged ref 0===========
at: typing
Dict = _alias(dict, 2, inst=False, name='Dict')
===========changed ref 0===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_padding_frame(self) -> Dict:
+ return {"frame_type": "padding"}
- return {"frame_type": "PADDING"}
===========changed ref 1===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_path_response_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "path_response"}
- return {"data": hexdump(data), "frame_type": "PATH_RESPONSE"}
===========changed ref 2===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_path_challenge_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "path_challenge"}
- return {"data": hexdump(data), "frame_type": "PATH_CHALLENGE"}
===========changed ref 3===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_new_token_frame(self, token: bytes) -> Dict:
return {
+ "frame_type": "new_token",
- "frame_type": "NEW_TOKEN",
"length": str(len(token)),
"token": hexdump(token),
}
===========changed ref 4===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_streams_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_streams", "maximum": str(maximum)}
- return {"frame_type": "MAX_STREAMS", "maximum": str(maximum)}
===========changed ref 5===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_data_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_data", "maximum": str(maximum)}
- return {"frame_type": "MAX_DATA", "maximum": str(maximum)}
===========changed ref 6===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_data_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "data_blocked", "limit": str(limit)}
- return {"frame_type": "DATA_BLOCKED", "limit": str(limit)}
===========changed ref 7===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_stream_data_frame(self, maximum: int, stream_id: int) -> Dict:
return {
+ "frame_type": "max_stream_data",
- "frame_type": "MAX_STREAM_DATA",
"id": str(stream_id),
"maximum": str(maximum),
}
===========changed ref 8===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_crypto_frame(self, frame: QuicStreamFrame) -> Dict:
return {
"fin": frame.fin,
+ "frame_type": "crypto",
- "frame_type": "CRYPTO",
"length": str(len(frame.data)),
"offset": str(frame.offset),
}
===========changed ref 9===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_new_connection_id_frame(self, frame: QuicNewConnectionIdFrame) -> Dict:
return {
"connection_id": hexdump(frame.connection_id),
+ "frame_type": "new_connection_id",
- "frame_type": "NEW_CONNECTION_ID",
"length": len(str(frame.connection_id)),
"reset_token": hexdump(frame.stateless_reset_token),
"retire_prior_to": str(frame.retire_prior_to),
"sequence_number": str(frame.sequence_number),
}
===========changed ref 10===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_ack_frame(self, ranges: RangeSet, delay: float) -> Dict:
return {
"ack_delay": str(int(delay * 1000)), # convert to ms
"acked_ranges": [[str(x.start), str(x.stop - 1)] for x in ranges],
+ "frame_type": "ack",
- "frame_type": "ACK",
}
===========changed ref 11===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_connection_close_frame(
self, error_code: int, frame_type: Optional[int], reason_phrase: str
) -> Dict:
attrs = {
"error_code": error_code,
"error_space": "application" if frame_type is None else "transport",
+ "frame_type": "connection_close",
- "frame_type": "CONNECTION_CLOSE",
"raw_error_code": error_code,
"reason": reason_phrase,
}
if frame_type is not None:
attrs["trigger_frame_type"] = frame_type
return attrs
===========changed ref 12===========
# module: aioquic.quic.logger
PACKET_TYPE_NAMES = {
+ PACKET_TYPE_INITIAL: "initial",
- PACKET_TYPE_INITIAL: "INITIAL",
+ PACKET_TYPE_HANDSHAKE: "handshake",
- PACKET_TYPE_HANDSHAKE: "HANDSHAKE",
PACKET_TYPE_ZERO_RTT: "0RTT",
PACKET_TYPE_ONE_RTT: "1RTT",
+ PACKET_TYPE_RETRY: "retry",
- PACKET_TYPE_RETRY: "RETRY",
}
|
aioquic.quic.logger/QuicLogger.encode_reset_stream_frame
|
Modified
|
aiortc~aioquic
|
f89f264ca7ff9bf69a5ec2c3550bb0ffa67db2da
|
[qlog] switch to draft-01
|
<3>:<add> "frame_type": "reset_stream",
<del> "frame_type": "RESET_STREAM",
|
# module: aioquic.quic.logger
class QuicLogger:
def encode_reset_stream_frame(
self, error_code: int, final_size: int, stream_id: int
) -> Dict:
<0> return {
<1> "error_code": error_code,
<2> "final_size": str(final_size),
<3> "frame_type": "RESET_STREAM",
<4> }
<5>
|
===========unchanged ref 0===========
at: typing
Dict = _alias(dict, 2, inst=False, name='Dict')
===========changed ref 0===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_ping_frame(self) -> Dict:
+ return {"frame_type": "ping"}
- return {"frame_type": "PING"}
===========changed ref 1===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_padding_frame(self) -> Dict:
+ return {"frame_type": "padding"}
- return {"frame_type": "PADDING"}
===========changed ref 2===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_path_response_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "path_response"}
- return {"data": hexdump(data), "frame_type": "PATH_RESPONSE"}
===========changed ref 3===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_path_challenge_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "path_challenge"}
- return {"data": hexdump(data), "frame_type": "PATH_CHALLENGE"}
===========changed ref 4===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_new_token_frame(self, token: bytes) -> Dict:
return {
+ "frame_type": "new_token",
- "frame_type": "NEW_TOKEN",
"length": str(len(token)),
"token": hexdump(token),
}
===========changed ref 5===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_streams_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_streams", "maximum": str(maximum)}
- return {"frame_type": "MAX_STREAMS", "maximum": str(maximum)}
===========changed ref 6===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_data_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_data", "maximum": str(maximum)}
- return {"frame_type": "MAX_DATA", "maximum": str(maximum)}
===========changed ref 7===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_data_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "data_blocked", "limit": str(limit)}
- return {"frame_type": "DATA_BLOCKED", "limit": str(limit)}
===========changed ref 8===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_stream_data_frame(self, maximum: int, stream_id: int) -> Dict:
return {
+ "frame_type": "max_stream_data",
- "frame_type": "MAX_STREAM_DATA",
"id": str(stream_id),
"maximum": str(maximum),
}
===========changed ref 9===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_crypto_frame(self, frame: QuicStreamFrame) -> Dict:
return {
"fin": frame.fin,
+ "frame_type": "crypto",
- "frame_type": "CRYPTO",
"length": str(len(frame.data)),
"offset": str(frame.offset),
}
===========changed ref 10===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_new_connection_id_frame(self, frame: QuicNewConnectionIdFrame) -> Dict:
return {
"connection_id": hexdump(frame.connection_id),
+ "frame_type": "new_connection_id",
- "frame_type": "NEW_CONNECTION_ID",
"length": len(str(frame.connection_id)),
"reset_token": hexdump(frame.stateless_reset_token),
"retire_prior_to": str(frame.retire_prior_to),
"sequence_number": str(frame.sequence_number),
}
===========changed ref 11===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_ack_frame(self, ranges: RangeSet, delay: float) -> Dict:
return {
"ack_delay": str(int(delay * 1000)), # convert to ms
"acked_ranges": [[str(x.start), str(x.stop - 1)] for x in ranges],
+ "frame_type": "ack",
- "frame_type": "ACK",
}
===========changed ref 12===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_connection_close_frame(
self, error_code: int, frame_type: Optional[int], reason_phrase: str
) -> Dict:
attrs = {
"error_code": error_code,
"error_space": "application" if frame_type is None else "transport",
+ "frame_type": "connection_close",
- "frame_type": "CONNECTION_CLOSE",
"raw_error_code": error_code,
"reason": reason_phrase,
}
if frame_type is not None:
attrs["trigger_frame_type"] = frame_type
return attrs
===========changed ref 13===========
# module: aioquic.quic.logger
PACKET_TYPE_NAMES = {
+ PACKET_TYPE_INITIAL: "initial",
- PACKET_TYPE_INITIAL: "INITIAL",
+ PACKET_TYPE_HANDSHAKE: "handshake",
- PACKET_TYPE_HANDSHAKE: "HANDSHAKE",
PACKET_TYPE_ZERO_RTT: "0RTT",
PACKET_TYPE_ONE_RTT: "1RTT",
+ PACKET_TYPE_RETRY: "retry",
- PACKET_TYPE_RETRY: "RETRY",
}
|
aioquic.quic.logger/QuicLogger.encode_retire_connection_id_frame
|
Modified
|
aiortc~aioquic
|
f89f264ca7ff9bf69a5ec2c3550bb0ffa67db2da
|
[qlog] switch to draft-01
|
<1>:<add> "frame_type": "retire_connection_id",
<del> "frame_type": "RETIRE_CONNECTION_ID",
|
# module: aioquic.quic.logger
class QuicLogger:
def encode_retire_connection_id_frame(self, sequence_number: int) -> Dict:
<0> return {
<1> "frame_type": "RETIRE_CONNECTION_ID",
<2> "sequence_number": str(sequence_number),
<3> }
<4>
|
===========unchanged ref 0===========
at: typing
Dict = _alias(dict, 2, inst=False, name='Dict')
===========changed ref 0===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_ping_frame(self) -> Dict:
+ return {"frame_type": "ping"}
- return {"frame_type": "PING"}
===========changed ref 1===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_padding_frame(self) -> Dict:
+ return {"frame_type": "padding"}
- return {"frame_type": "PADDING"}
===========changed ref 2===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_reset_stream_frame(
self, error_code: int, final_size: int, stream_id: int
) -> Dict:
return {
"error_code": error_code,
"final_size": str(final_size),
+ "frame_type": "reset_stream",
- "frame_type": "RESET_STREAM",
}
===========changed ref 3===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_path_response_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "path_response"}
- return {"data": hexdump(data), "frame_type": "PATH_RESPONSE"}
===========changed ref 4===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_path_challenge_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "path_challenge"}
- return {"data": hexdump(data), "frame_type": "PATH_CHALLENGE"}
===========changed ref 5===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_new_token_frame(self, token: bytes) -> Dict:
return {
+ "frame_type": "new_token",
- "frame_type": "NEW_TOKEN",
"length": str(len(token)),
"token": hexdump(token),
}
===========changed ref 6===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_streams_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_streams", "maximum": str(maximum)}
- return {"frame_type": "MAX_STREAMS", "maximum": str(maximum)}
===========changed ref 7===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_data_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_data", "maximum": str(maximum)}
- return {"frame_type": "MAX_DATA", "maximum": str(maximum)}
===========changed ref 8===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_data_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "data_blocked", "limit": str(limit)}
- return {"frame_type": "DATA_BLOCKED", "limit": str(limit)}
===========changed ref 9===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_stream_data_frame(self, maximum: int, stream_id: int) -> Dict:
return {
+ "frame_type": "max_stream_data",
- "frame_type": "MAX_STREAM_DATA",
"id": str(stream_id),
"maximum": str(maximum),
}
===========changed ref 10===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_crypto_frame(self, frame: QuicStreamFrame) -> Dict:
return {
"fin": frame.fin,
+ "frame_type": "crypto",
- "frame_type": "CRYPTO",
"length": str(len(frame.data)),
"offset": str(frame.offset),
}
===========changed ref 11===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_new_connection_id_frame(self, frame: QuicNewConnectionIdFrame) -> Dict:
return {
"connection_id": hexdump(frame.connection_id),
+ "frame_type": "new_connection_id",
- "frame_type": "NEW_CONNECTION_ID",
"length": len(str(frame.connection_id)),
"reset_token": hexdump(frame.stateless_reset_token),
"retire_prior_to": str(frame.retire_prior_to),
"sequence_number": str(frame.sequence_number),
}
===========changed ref 12===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_ack_frame(self, ranges: RangeSet, delay: float) -> Dict:
return {
"ack_delay": str(int(delay * 1000)), # convert to ms
"acked_ranges": [[str(x.start), str(x.stop - 1)] for x in ranges],
+ "frame_type": "ack",
- "frame_type": "ACK",
}
===========changed ref 13===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_connection_close_frame(
self, error_code: int, frame_type: Optional[int], reason_phrase: str
) -> Dict:
attrs = {
"error_code": error_code,
"error_space": "application" if frame_type is None else "transport",
+ "frame_type": "connection_close",
- "frame_type": "CONNECTION_CLOSE",
"raw_error_code": error_code,
"reason": reason_phrase,
}
if frame_type is not None:
attrs["trigger_frame_type"] = frame_type
return attrs
===========changed ref 14===========
# module: aioquic.quic.logger
PACKET_TYPE_NAMES = {
+ PACKET_TYPE_INITIAL: "initial",
- PACKET_TYPE_INITIAL: "INITIAL",
+ PACKET_TYPE_HANDSHAKE: "handshake",
- PACKET_TYPE_HANDSHAKE: "HANDSHAKE",
PACKET_TYPE_ZERO_RTT: "0RTT",
PACKET_TYPE_ONE_RTT: "1RTT",
+ PACKET_TYPE_RETRY: "retry",
- PACKET_TYPE_RETRY: "RETRY",
}
|
aioquic.quic.logger/QuicLogger.encode_stream_data_blocked_frame
|
Modified
|
aiortc~aioquic
|
f89f264ca7ff9bf69a5ec2c3550bb0ffa67db2da
|
[qlog] switch to draft-01
|
<1>:<add> "frame_type": "stream_data_blocked",
<del> "frame_type": "STREAM_DATA_BLOCKED",
|
# module: aioquic.quic.logger
class QuicLogger:
def encode_stream_data_blocked_frame(self, limit: int, stream_id: int) -> Dict:
<0> return {
<1> "frame_type": "STREAM_DATA_BLOCKED",
<2> "limit": str(limit),
<3> "stream_id": str(stream_id),
<4> }
<5>
|
===========unchanged ref 0===========
at: typing
Dict = _alias(dict, 2, inst=False, name='Dict')
===========changed ref 0===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_ping_frame(self) -> Dict:
+ return {"frame_type": "ping"}
- return {"frame_type": "PING"}
===========changed ref 1===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_padding_frame(self) -> Dict:
+ return {"frame_type": "padding"}
- return {"frame_type": "PADDING"}
===========changed ref 2===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_retire_connection_id_frame(self, sequence_number: int) -> Dict:
return {
+ "frame_type": "retire_connection_id",
- "frame_type": "RETIRE_CONNECTION_ID",
"sequence_number": str(sequence_number),
}
===========changed ref 3===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_reset_stream_frame(
self, error_code: int, final_size: int, stream_id: int
) -> Dict:
return {
"error_code": error_code,
"final_size": str(final_size),
+ "frame_type": "reset_stream",
- "frame_type": "RESET_STREAM",
}
===========changed ref 4===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_path_response_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "path_response"}
- return {"data": hexdump(data), "frame_type": "PATH_RESPONSE"}
===========changed ref 5===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_path_challenge_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "path_challenge"}
- return {"data": hexdump(data), "frame_type": "PATH_CHALLENGE"}
===========changed ref 6===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_new_token_frame(self, token: bytes) -> Dict:
return {
+ "frame_type": "new_token",
- "frame_type": "NEW_TOKEN",
"length": str(len(token)),
"token": hexdump(token),
}
===========changed ref 7===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_streams_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_streams", "maximum": str(maximum)}
- return {"frame_type": "MAX_STREAMS", "maximum": str(maximum)}
===========changed ref 8===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_data_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_data", "maximum": str(maximum)}
- return {"frame_type": "MAX_DATA", "maximum": str(maximum)}
===========changed ref 9===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_data_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "data_blocked", "limit": str(limit)}
- return {"frame_type": "DATA_BLOCKED", "limit": str(limit)}
===========changed ref 10===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_stream_data_frame(self, maximum: int, stream_id: int) -> Dict:
return {
+ "frame_type": "max_stream_data",
- "frame_type": "MAX_STREAM_DATA",
"id": str(stream_id),
"maximum": str(maximum),
}
===========changed ref 11===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_crypto_frame(self, frame: QuicStreamFrame) -> Dict:
return {
"fin": frame.fin,
+ "frame_type": "crypto",
- "frame_type": "CRYPTO",
"length": str(len(frame.data)),
"offset": str(frame.offset),
}
===========changed ref 12===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_new_connection_id_frame(self, frame: QuicNewConnectionIdFrame) -> Dict:
return {
"connection_id": hexdump(frame.connection_id),
+ "frame_type": "new_connection_id",
- "frame_type": "NEW_CONNECTION_ID",
"length": len(str(frame.connection_id)),
"reset_token": hexdump(frame.stateless_reset_token),
"retire_prior_to": str(frame.retire_prior_to),
"sequence_number": str(frame.sequence_number),
}
===========changed ref 13===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_ack_frame(self, ranges: RangeSet, delay: float) -> Dict:
return {
"ack_delay": str(int(delay * 1000)), # convert to ms
"acked_ranges": [[str(x.start), str(x.stop - 1)] for x in ranges],
+ "frame_type": "ack",
- "frame_type": "ACK",
}
===========changed ref 14===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_connection_close_frame(
self, error_code: int, frame_type: Optional[int], reason_phrase: str
) -> Dict:
attrs = {
"error_code": error_code,
"error_space": "application" if frame_type is None else "transport",
+ "frame_type": "connection_close",
- "frame_type": "CONNECTION_CLOSE",
"raw_error_code": error_code,
"reason": reason_phrase,
}
if frame_type is not None:
attrs["trigger_frame_type"] = frame_type
return attrs
===========changed ref 15===========
# module: aioquic.quic.logger
PACKET_TYPE_NAMES = {
+ PACKET_TYPE_INITIAL: "initial",
- PACKET_TYPE_INITIAL: "INITIAL",
+ PACKET_TYPE_HANDSHAKE: "handshake",
- PACKET_TYPE_HANDSHAKE: "HANDSHAKE",
PACKET_TYPE_ZERO_RTT: "0RTT",
PACKET_TYPE_ONE_RTT: "1RTT",
+ PACKET_TYPE_RETRY: "retry",
- PACKET_TYPE_RETRY: "RETRY",
}
|
aioquic.quic.logger/QuicLogger.encode_stop_sending_frame
|
Modified
|
aiortc~aioquic
|
f89f264ca7ff9bf69a5ec2c3550bb0ffa67db2da
|
[qlog] switch to draft-01
|
<1>:<add> "frame_type": "stop_sending",
<del> "frame_type": "STOP_SENDING",
|
# module: aioquic.quic.logger
class QuicLogger:
def encode_stop_sending_frame(self, error_code: int, stream_id: int) -> Dict:
<0> return {
<1> "frame_type": "STOP_SENDING",
<2> "id": str(stream_id),
<3> "error_code": error_code,
<4> }
<5>
|
===========unchanged ref 0===========
at: typing
Dict = _alias(dict, 2, inst=False, name='Dict')
===========changed ref 0===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_ping_frame(self) -> Dict:
+ return {"frame_type": "ping"}
- return {"frame_type": "PING"}
===========changed ref 1===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_padding_frame(self) -> Dict:
+ return {"frame_type": "padding"}
- return {"frame_type": "PADDING"}
===========changed ref 2===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_stream_data_blocked_frame(self, limit: int, stream_id: int) -> Dict:
return {
+ "frame_type": "stream_data_blocked",
- "frame_type": "STREAM_DATA_BLOCKED",
"limit": str(limit),
"stream_id": str(stream_id),
}
===========changed ref 3===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_retire_connection_id_frame(self, sequence_number: int) -> Dict:
return {
+ "frame_type": "retire_connection_id",
- "frame_type": "RETIRE_CONNECTION_ID",
"sequence_number": str(sequence_number),
}
===========changed ref 4===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_reset_stream_frame(
self, error_code: int, final_size: int, stream_id: int
) -> Dict:
return {
"error_code": error_code,
"final_size": str(final_size),
+ "frame_type": "reset_stream",
- "frame_type": "RESET_STREAM",
}
===========changed ref 5===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_path_response_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "path_response"}
- return {"data": hexdump(data), "frame_type": "PATH_RESPONSE"}
===========changed ref 6===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_path_challenge_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "path_challenge"}
- return {"data": hexdump(data), "frame_type": "PATH_CHALLENGE"}
===========changed ref 7===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_new_token_frame(self, token: bytes) -> Dict:
return {
+ "frame_type": "new_token",
- "frame_type": "NEW_TOKEN",
"length": str(len(token)),
"token": hexdump(token),
}
===========changed ref 8===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_streams_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_streams", "maximum": str(maximum)}
- return {"frame_type": "MAX_STREAMS", "maximum": str(maximum)}
===========changed ref 9===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_data_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_data", "maximum": str(maximum)}
- return {"frame_type": "MAX_DATA", "maximum": str(maximum)}
===========changed ref 10===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_data_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "data_blocked", "limit": str(limit)}
- return {"frame_type": "DATA_BLOCKED", "limit": str(limit)}
===========changed ref 11===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_stream_data_frame(self, maximum: int, stream_id: int) -> Dict:
return {
+ "frame_type": "max_stream_data",
- "frame_type": "MAX_STREAM_DATA",
"id": str(stream_id),
"maximum": str(maximum),
}
===========changed ref 12===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_crypto_frame(self, frame: QuicStreamFrame) -> Dict:
return {
"fin": frame.fin,
+ "frame_type": "crypto",
- "frame_type": "CRYPTO",
"length": str(len(frame.data)),
"offset": str(frame.offset),
}
===========changed ref 13===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_new_connection_id_frame(self, frame: QuicNewConnectionIdFrame) -> Dict:
return {
"connection_id": hexdump(frame.connection_id),
+ "frame_type": "new_connection_id",
- "frame_type": "NEW_CONNECTION_ID",
"length": len(str(frame.connection_id)),
"reset_token": hexdump(frame.stateless_reset_token),
"retire_prior_to": str(frame.retire_prior_to),
"sequence_number": str(frame.sequence_number),
}
===========changed ref 14===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_ack_frame(self, ranges: RangeSet, delay: float) -> Dict:
return {
"ack_delay": str(int(delay * 1000)), # convert to ms
"acked_ranges": [[str(x.start), str(x.stop - 1)] for x in ranges],
+ "frame_type": "ack",
- "frame_type": "ACK",
}
===========changed ref 15===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_connection_close_frame(
self, error_code: int, frame_type: Optional[int], reason_phrase: str
) -> Dict:
attrs = {
"error_code": error_code,
"error_space": "application" if frame_type is None else "transport",
+ "frame_type": "connection_close",
- "frame_type": "CONNECTION_CLOSE",
"raw_error_code": error_code,
"reason": reason_phrase,
}
if frame_type is not None:
attrs["trigger_frame_type"] = frame_type
return attrs
===========changed ref 16===========
# module: aioquic.quic.logger
PACKET_TYPE_NAMES = {
+ PACKET_TYPE_INITIAL: "initial",
- PACKET_TYPE_INITIAL: "INITIAL",
+ PACKET_TYPE_HANDSHAKE: "handshake",
- PACKET_TYPE_HANDSHAKE: "HANDSHAKE",
PACKET_TYPE_ZERO_RTT: "0RTT",
PACKET_TYPE_ONE_RTT: "1RTT",
+ PACKET_TYPE_RETRY: "retry",
- PACKET_TYPE_RETRY: "RETRY",
}
|
aioquic.quic.logger/QuicLogger.encode_stream_frame
|
Modified
|
aiortc~aioquic
|
f89f264ca7ff9bf69a5ec2c3550bb0ffa67db2da
|
[qlog] switch to draft-01
|
<2>:<add> "frame_type": "stream",
<del> "frame_type": "STREAM",
|
# module: aioquic.quic.logger
class QuicLogger:
def encode_stream_frame(self, frame: QuicStreamFrame, stream_id: int) -> Dict:
<0> return {
<1> "fin": frame.fin,
<2> "frame_type": "STREAM",
<3> "id": str(stream_id),
<4> "length": str(len(frame.data)),
<5> "offset": str(frame.offset),
<6> }
<7>
|
===========unchanged ref 0===========
at: aioquic.quic.packet
QuicStreamFrame(data: bytes=b"", fin: bool=False, offset: int=0)
at: aioquic.quic.packet.QuicStreamFrame
data: bytes = b""
fin: bool = False
offset: int = 0
at: typing
Dict = _alias(dict, 2, inst=False, name='Dict')
===========changed ref 0===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_ping_frame(self) -> Dict:
+ return {"frame_type": "ping"}
- return {"frame_type": "PING"}
===========changed ref 1===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_stop_sending_frame(self, error_code: int, stream_id: int) -> Dict:
return {
+ "frame_type": "stop_sending",
- "frame_type": "STOP_SENDING",
"id": str(stream_id),
"error_code": error_code,
}
===========changed ref 2===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_padding_frame(self) -> Dict:
+ return {"frame_type": "padding"}
- return {"frame_type": "PADDING"}
===========changed ref 3===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_stream_data_blocked_frame(self, limit: int, stream_id: int) -> Dict:
return {
+ "frame_type": "stream_data_blocked",
- "frame_type": "STREAM_DATA_BLOCKED",
"limit": str(limit),
"stream_id": str(stream_id),
}
===========changed ref 4===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_retire_connection_id_frame(self, sequence_number: int) -> Dict:
return {
+ "frame_type": "retire_connection_id",
- "frame_type": "RETIRE_CONNECTION_ID",
"sequence_number": str(sequence_number),
}
===========changed ref 5===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_reset_stream_frame(
self, error_code: int, final_size: int, stream_id: int
) -> Dict:
return {
"error_code": error_code,
"final_size": str(final_size),
+ "frame_type": "reset_stream",
- "frame_type": "RESET_STREAM",
}
===========changed ref 6===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_path_response_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "path_response"}
- return {"data": hexdump(data), "frame_type": "PATH_RESPONSE"}
===========changed ref 7===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_path_challenge_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "path_challenge"}
- return {"data": hexdump(data), "frame_type": "PATH_CHALLENGE"}
===========changed ref 8===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_new_token_frame(self, token: bytes) -> Dict:
return {
+ "frame_type": "new_token",
- "frame_type": "NEW_TOKEN",
"length": str(len(token)),
"token": hexdump(token),
}
===========changed ref 9===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_streams_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_streams", "maximum": str(maximum)}
- return {"frame_type": "MAX_STREAMS", "maximum": str(maximum)}
===========changed ref 10===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_data_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_data", "maximum": str(maximum)}
- return {"frame_type": "MAX_DATA", "maximum": str(maximum)}
===========changed ref 11===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_data_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "data_blocked", "limit": str(limit)}
- return {"frame_type": "DATA_BLOCKED", "limit": str(limit)}
===========changed ref 12===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_stream_data_frame(self, maximum: int, stream_id: int) -> Dict:
return {
+ "frame_type": "max_stream_data",
- "frame_type": "MAX_STREAM_DATA",
"id": str(stream_id),
"maximum": str(maximum),
}
===========changed ref 13===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_crypto_frame(self, frame: QuicStreamFrame) -> Dict:
return {
"fin": frame.fin,
+ "frame_type": "crypto",
- "frame_type": "CRYPTO",
"length": str(len(frame.data)),
"offset": str(frame.offset),
}
===========changed ref 14===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_new_connection_id_frame(self, frame: QuicNewConnectionIdFrame) -> Dict:
return {
"connection_id": hexdump(frame.connection_id),
+ "frame_type": "new_connection_id",
- "frame_type": "NEW_CONNECTION_ID",
"length": len(str(frame.connection_id)),
"reset_token": hexdump(frame.stateless_reset_token),
"retire_prior_to": str(frame.retire_prior_to),
"sequence_number": str(frame.sequence_number),
}
===========changed ref 15===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_ack_frame(self, ranges: RangeSet, delay: float) -> Dict:
return {
"ack_delay": str(int(delay * 1000)), # convert to ms
"acked_ranges": [[str(x.start), str(x.stop - 1)] for x in ranges],
+ "frame_type": "ack",
- "frame_type": "ACK",
}
===========changed ref 16===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_connection_close_frame(
self, error_code: int, frame_type: Optional[int], reason_phrase: str
) -> Dict:
attrs = {
"error_code": error_code,
"error_space": "application" if frame_type is None else "transport",
+ "frame_type": "connection_close",
- "frame_type": "CONNECTION_CLOSE",
"raw_error_code": error_code,
"reason": reason_phrase,
}
if frame_type is not None:
attrs["trigger_frame_type"] = frame_type
return attrs
===========changed ref 17===========
# module: aioquic.quic.logger
PACKET_TYPE_NAMES = {
+ PACKET_TYPE_INITIAL: "initial",
- PACKET_TYPE_INITIAL: "INITIAL",
+ PACKET_TYPE_HANDSHAKE: "handshake",
- PACKET_TYPE_HANDSHAKE: "HANDSHAKE",
PACKET_TYPE_ZERO_RTT: "0RTT",
PACKET_TYPE_ONE_RTT: "1RTT",
+ PACKET_TYPE_RETRY: "retry",
- PACKET_TYPE_RETRY: "RETRY",
}
|
aioquic.quic.logger/QuicLogger.encode_streams_blocked_frame
|
Modified
|
aiortc~aioquic
|
f89f264ca7ff9bf69a5ec2c3550bb0ffa67db2da
|
[qlog] switch to draft-01
|
<0>:<add> return {"frame_type": "streams_blocked", "limit": str(limit)}
<del> return {"frame_type": "STREAMS_BLOCKED", "limit": str(limit)}
|
# module: aioquic.quic.logger
class QuicLogger:
def encode_streams_blocked_frame(self, limit: int) -> Dict:
<0> return {"frame_type": "STREAMS_BLOCKED", "limit": str(limit)}
<1>
|
===========unchanged ref 0===========
at: typing
Dict = _alias(dict, 2, inst=False, name='Dict')
===========changed ref 0===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_ping_frame(self) -> Dict:
+ return {"frame_type": "ping"}
- return {"frame_type": "PING"}
===========changed ref 1===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_stop_sending_frame(self, error_code: int, stream_id: int) -> Dict:
return {
+ "frame_type": "stop_sending",
- "frame_type": "STOP_SENDING",
"id": str(stream_id),
"error_code": error_code,
}
===========changed ref 2===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_stream_frame(self, frame: QuicStreamFrame, stream_id: int) -> Dict:
return {
"fin": frame.fin,
+ "frame_type": "stream",
- "frame_type": "STREAM",
"id": str(stream_id),
"length": str(len(frame.data)),
"offset": str(frame.offset),
}
===========changed ref 3===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_padding_frame(self) -> Dict:
+ return {"frame_type": "padding"}
- return {"frame_type": "PADDING"}
===========changed ref 4===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_stream_data_blocked_frame(self, limit: int, stream_id: int) -> Dict:
return {
+ "frame_type": "stream_data_blocked",
- "frame_type": "STREAM_DATA_BLOCKED",
"limit": str(limit),
"stream_id": str(stream_id),
}
===========changed ref 5===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_retire_connection_id_frame(self, sequence_number: int) -> Dict:
return {
+ "frame_type": "retire_connection_id",
- "frame_type": "RETIRE_CONNECTION_ID",
"sequence_number": str(sequence_number),
}
===========changed ref 6===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_reset_stream_frame(
self, error_code: int, final_size: int, stream_id: int
) -> Dict:
return {
"error_code": error_code,
"final_size": str(final_size),
+ "frame_type": "reset_stream",
- "frame_type": "RESET_STREAM",
}
===========changed ref 7===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_path_response_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "path_response"}
- return {"data": hexdump(data), "frame_type": "PATH_RESPONSE"}
===========changed ref 8===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_path_challenge_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "path_challenge"}
- return {"data": hexdump(data), "frame_type": "PATH_CHALLENGE"}
===========changed ref 9===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_new_token_frame(self, token: bytes) -> Dict:
return {
+ "frame_type": "new_token",
- "frame_type": "NEW_TOKEN",
"length": str(len(token)),
"token": hexdump(token),
}
===========changed ref 10===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_streams_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_streams", "maximum": str(maximum)}
- return {"frame_type": "MAX_STREAMS", "maximum": str(maximum)}
===========changed ref 11===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_data_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_data", "maximum": str(maximum)}
- return {"frame_type": "MAX_DATA", "maximum": str(maximum)}
===========changed ref 12===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_data_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "data_blocked", "limit": str(limit)}
- return {"frame_type": "DATA_BLOCKED", "limit": str(limit)}
===========changed ref 13===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_stream_data_frame(self, maximum: int, stream_id: int) -> Dict:
return {
+ "frame_type": "max_stream_data",
- "frame_type": "MAX_STREAM_DATA",
"id": str(stream_id),
"maximum": str(maximum),
}
===========changed ref 14===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_crypto_frame(self, frame: QuicStreamFrame) -> Dict:
return {
"fin": frame.fin,
+ "frame_type": "crypto",
- "frame_type": "CRYPTO",
"length": str(len(frame.data)),
"offset": str(frame.offset),
}
===========changed ref 15===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_new_connection_id_frame(self, frame: QuicNewConnectionIdFrame) -> Dict:
return {
"connection_id": hexdump(frame.connection_id),
+ "frame_type": "new_connection_id",
- "frame_type": "NEW_CONNECTION_ID",
"length": len(str(frame.connection_id)),
"reset_token": hexdump(frame.stateless_reset_token),
"retire_prior_to": str(frame.retire_prior_to),
"sequence_number": str(frame.sequence_number),
}
===========changed ref 16===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_ack_frame(self, ranges: RangeSet, delay: float) -> Dict:
return {
"ack_delay": str(int(delay * 1000)), # convert to ms
"acked_ranges": [[str(x.start), str(x.stop - 1)] for x in ranges],
+ "frame_type": "ack",
- "frame_type": "ACK",
}
===========changed ref 17===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_connection_close_frame(
self, error_code: int, frame_type: Optional[int], reason_phrase: str
) -> Dict:
attrs = {
"error_code": error_code,
"error_space": "application" if frame_type is None else "transport",
+ "frame_type": "connection_close",
- "frame_type": "CONNECTION_CLOSE",
"raw_error_code": error_code,
"reason": reason_phrase,
}
if frame_type is not None:
attrs["trigger_frame_type"] = frame_type
return attrs
===========changed ref 18===========
# module: aioquic.quic.logger
PACKET_TYPE_NAMES = {
+ PACKET_TYPE_INITIAL: "initial",
- PACKET_TYPE_INITIAL: "INITIAL",
+ PACKET_TYPE_HANDSHAKE: "handshake",
- PACKET_TYPE_HANDSHAKE: "HANDSHAKE",
PACKET_TYPE_ZERO_RTT: "0RTT",
PACKET_TYPE_ONE_RTT: "1RTT",
+ PACKET_TYPE_RETRY: "retry",
- PACKET_TYPE_RETRY: "RETRY",
}
|
aioquic.quic.logger/QuicLogger.start_trace
|
Modified
|
aiortc~aioquic
|
f89f264ca7ff9bf69a5ec2c3550bb0ffa67db2da
|
[qlog] switch to draft-01
|
<0>:<add> self._vantage_point["type"] = "client" if is_client else "server"
<del> self._vantage_point["type"] = "CLIENT" if is_client else "SERVER"
|
# module: aioquic.quic.logger
class QuicLogger:
def start_trace(self, is_client: bool) -> None:
<0> self._vantage_point["type"] = "CLIENT" if is_client else "SERVER"
<1>
|
===========unchanged ref 0===========
at: aioquic.quic.logger.QuicLogger.__init__
self._vantage_point = {"name": "aioquic", "type": "unknown"}
===========changed ref 0===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_streams_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "streams_blocked", "limit": str(limit)}
- return {"frame_type": "STREAMS_BLOCKED", "limit": str(limit)}
===========changed ref 1===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_ping_frame(self) -> Dict:
+ return {"frame_type": "ping"}
- return {"frame_type": "PING"}
===========changed ref 2===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_stop_sending_frame(self, error_code: int, stream_id: int) -> Dict:
return {
+ "frame_type": "stop_sending",
- "frame_type": "STOP_SENDING",
"id": str(stream_id),
"error_code": error_code,
}
===========changed ref 3===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_stream_frame(self, frame: QuicStreamFrame, stream_id: int) -> Dict:
return {
"fin": frame.fin,
+ "frame_type": "stream",
- "frame_type": "STREAM",
"id": str(stream_id),
"length": str(len(frame.data)),
"offset": str(frame.offset),
}
===========changed ref 4===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_padding_frame(self) -> Dict:
+ return {"frame_type": "padding"}
- return {"frame_type": "PADDING"}
===========changed ref 5===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_stream_data_blocked_frame(self, limit: int, stream_id: int) -> Dict:
return {
+ "frame_type": "stream_data_blocked",
- "frame_type": "STREAM_DATA_BLOCKED",
"limit": str(limit),
"stream_id": str(stream_id),
}
===========changed ref 6===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_retire_connection_id_frame(self, sequence_number: int) -> Dict:
return {
+ "frame_type": "retire_connection_id",
- "frame_type": "RETIRE_CONNECTION_ID",
"sequence_number": str(sequence_number),
}
===========changed ref 7===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_reset_stream_frame(
self, error_code: int, final_size: int, stream_id: int
) -> Dict:
return {
"error_code": error_code,
"final_size": str(final_size),
+ "frame_type": "reset_stream",
- "frame_type": "RESET_STREAM",
}
===========changed ref 8===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_path_response_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "path_response"}
- return {"data": hexdump(data), "frame_type": "PATH_RESPONSE"}
===========changed ref 9===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_path_challenge_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "path_challenge"}
- return {"data": hexdump(data), "frame_type": "PATH_CHALLENGE"}
===========changed ref 10===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_new_token_frame(self, token: bytes) -> Dict:
return {
+ "frame_type": "new_token",
- "frame_type": "NEW_TOKEN",
"length": str(len(token)),
"token": hexdump(token),
}
===========changed ref 11===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_streams_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_streams", "maximum": str(maximum)}
- return {"frame_type": "MAX_STREAMS", "maximum": str(maximum)}
===========changed ref 12===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_data_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_data", "maximum": str(maximum)}
- return {"frame_type": "MAX_DATA", "maximum": str(maximum)}
===========changed ref 13===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_data_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "data_blocked", "limit": str(limit)}
- return {"frame_type": "DATA_BLOCKED", "limit": str(limit)}
===========changed ref 14===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_stream_data_frame(self, maximum: int, stream_id: int) -> Dict:
return {
+ "frame_type": "max_stream_data",
- "frame_type": "MAX_STREAM_DATA",
"id": str(stream_id),
"maximum": str(maximum),
}
===========changed ref 15===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_crypto_frame(self, frame: QuicStreamFrame) -> Dict:
return {
"fin": frame.fin,
+ "frame_type": "crypto",
- "frame_type": "CRYPTO",
"length": str(len(frame.data)),
"offset": str(frame.offset),
}
===========changed ref 16===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_new_connection_id_frame(self, frame: QuicNewConnectionIdFrame) -> Dict:
return {
"connection_id": hexdump(frame.connection_id),
+ "frame_type": "new_connection_id",
- "frame_type": "NEW_CONNECTION_ID",
"length": len(str(frame.connection_id)),
"reset_token": hexdump(frame.stateless_reset_token),
"retire_prior_to": str(frame.retire_prior_to),
"sequence_number": str(frame.sequence_number),
}
===========changed ref 17===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_ack_frame(self, ranges: RangeSet, delay: float) -> Dict:
return {
"ack_delay": str(int(delay * 1000)), # convert to ms
"acked_ranges": [[str(x.start), str(x.stop - 1)] for x in ranges],
+ "frame_type": "ack",
- "frame_type": "ACK",
}
===========changed ref 18===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_connection_close_frame(
self, error_code: int, frame_type: Optional[int], reason_phrase: str
) -> Dict:
attrs = {
"error_code": error_code,
"error_space": "application" if frame_type is None else "transport",
+ "frame_type": "connection_close",
- "frame_type": "CONNECTION_CLOSE",
"raw_error_code": error_code,
"reason": reason_phrase,
}
if frame_type is not None:
attrs["trigger_frame_type"] = frame_type
return attrs
|
aioquic.quic.logger/QuicLogger.to_dict
|
Modified
|
aiortc~aioquic
|
f89f264ca7ff9bf69a5ec2c3550bb0ffa67db2da
|
[qlog] switch to draft-01
|
<8>:<add> "event_fields": ["relative_time", "category", "event_type", "data"],
<del> "event_fields": ["relative_time", "CATEGORY", "EVENT_TYPE", "DATA"],
<24>:<add> return {"qlog_version": "draft-01", "traces": traces}
<del> return {"qlog_version": "draft-00", "traces": traces}
|
# module: aioquic.quic.logger
class QuicLogger:
def to_dict(self) -> Dict[str, Any]:
<0> """
<1> Return the trace as a dictionary which can be written as JSON.
<2> """
<3> traces = []
<4> if self._events:
<5> reference_time = self._events[0][0]
<6> trace = {
<7> "common_fields": {"reference_time": "%d" % (reference_time * 1000)},
<8> "event_fields": ["relative_time", "CATEGORY", "EVENT_TYPE", "DATA"],
<9> "events": list(
<10> map(
<11> lambda event: (
<12> "%d" % ((event[0] - reference_time) * 1000),
<13> event[1],
<14> event[2],
<15> event[3],
<16> ),
<17> self._events,
<18> )
<19> ),
<20> "vantage_point": self._vantage_point,
<21> }
<22> traces.append(trace)
<23>
<24> return {"qlog_version": "draft-00", "traces": traces}
<25>
|
===========unchanged ref 0===========
at: aioquic.quic.logger.QuicLogger.__init__
self._events: Deque[Tuple[float, str, str, Dict[str, Any]]] = deque()
self._vantage_point = {"name": "aioquic", "type": "unknown"}
at: typing
Dict = _alias(dict, 2, inst=False, name='Dict')
===========changed ref 0===========
# module: aioquic.quic.logger
class QuicLogger:
def start_trace(self, is_client: bool) -> None:
+ self._vantage_point["type"] = "client" if is_client else "server"
- self._vantage_point["type"] = "CLIENT" if is_client else "SERVER"
===========changed ref 1===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_streams_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "streams_blocked", "limit": str(limit)}
- return {"frame_type": "STREAMS_BLOCKED", "limit": str(limit)}
===========changed ref 2===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_ping_frame(self) -> Dict:
+ return {"frame_type": "ping"}
- return {"frame_type": "PING"}
===========changed ref 3===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_stop_sending_frame(self, error_code: int, stream_id: int) -> Dict:
return {
+ "frame_type": "stop_sending",
- "frame_type": "STOP_SENDING",
"id": str(stream_id),
"error_code": error_code,
}
===========changed ref 4===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_stream_frame(self, frame: QuicStreamFrame, stream_id: int) -> Dict:
return {
"fin": frame.fin,
+ "frame_type": "stream",
- "frame_type": "STREAM",
"id": str(stream_id),
"length": str(len(frame.data)),
"offset": str(frame.offset),
}
===========changed ref 5===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_padding_frame(self) -> Dict:
+ return {"frame_type": "padding"}
- return {"frame_type": "PADDING"}
===========changed ref 6===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_stream_data_blocked_frame(self, limit: int, stream_id: int) -> Dict:
return {
+ "frame_type": "stream_data_blocked",
- "frame_type": "STREAM_DATA_BLOCKED",
"limit": str(limit),
"stream_id": str(stream_id),
}
===========changed ref 7===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_retire_connection_id_frame(self, sequence_number: int) -> Dict:
return {
+ "frame_type": "retire_connection_id",
- "frame_type": "RETIRE_CONNECTION_ID",
"sequence_number": str(sequence_number),
}
===========changed ref 8===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_reset_stream_frame(
self, error_code: int, final_size: int, stream_id: int
) -> Dict:
return {
"error_code": error_code,
"final_size": str(final_size),
+ "frame_type": "reset_stream",
- "frame_type": "RESET_STREAM",
}
===========changed ref 9===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_path_response_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "path_response"}
- return {"data": hexdump(data), "frame_type": "PATH_RESPONSE"}
===========changed ref 10===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_path_challenge_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "path_challenge"}
- return {"data": hexdump(data), "frame_type": "PATH_CHALLENGE"}
===========changed ref 11===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_new_token_frame(self, token: bytes) -> Dict:
return {
+ "frame_type": "new_token",
- "frame_type": "NEW_TOKEN",
"length": str(len(token)),
"token": hexdump(token),
}
===========changed ref 12===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_streams_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_streams", "maximum": str(maximum)}
- return {"frame_type": "MAX_STREAMS", "maximum": str(maximum)}
===========changed ref 13===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_data_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_data", "maximum": str(maximum)}
- return {"frame_type": "MAX_DATA", "maximum": str(maximum)}
===========changed ref 14===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_data_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "data_blocked", "limit": str(limit)}
- return {"frame_type": "DATA_BLOCKED", "limit": str(limit)}
===========changed ref 15===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_stream_data_frame(self, maximum: int, stream_id: int) -> Dict:
return {
+ "frame_type": "max_stream_data",
- "frame_type": "MAX_STREAM_DATA",
"id": str(stream_id),
"maximum": str(maximum),
}
===========changed ref 16===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_crypto_frame(self, frame: QuicStreamFrame) -> Dict:
return {
"fin": frame.fin,
+ "frame_type": "crypto",
- "frame_type": "CRYPTO",
"length": str(len(frame.data)),
"offset": str(frame.offset),
}
===========changed ref 17===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_new_connection_id_frame(self, frame: QuicNewConnectionIdFrame) -> Dict:
return {
"connection_id": hexdump(frame.connection_id),
+ "frame_type": "new_connection_id",
- "frame_type": "NEW_CONNECTION_ID",
"length": len(str(frame.connection_id)),
"reset_token": hexdump(frame.stateless_reset_token),
"retire_prior_to": str(frame.retire_prior_to),
"sequence_number": str(frame.sequence_number),
}
===========changed ref 18===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_ack_frame(self, ranges: RangeSet, delay: float) -> Dict:
return {
"ack_delay": str(int(delay * 1000)), # convert to ms
"acked_ranges": [[str(x.start), str(x.stop - 1)] for x in ranges],
+ "frame_type": "ack",
- "frame_type": "ACK",
}
|
aioquic.quic.packet_builder/QuicPacketBuilder.__init__
|
Modified
|
aiortc~aioquic
|
f89f264ca7ff9bf69a5ec2c3550bb0ffa67db2da
|
[qlog] switch to draft-01
|
<2>:<add> self.quic_logger_frames: Optional[List[Dict]] = None
|
# module: aioquic.quic.packet_builder
class QuicPacketBuilder:
def __init__(
self,
*,
host_cid: bytes,
peer_cid: bytes,
version: int,
pad_first_datagram: bool = False,
packet_number: int = 0,
peer_token: bytes = b"",
quic_logger: Optional[QuicLogger] = None,
spin_bit: bool = False,
):
<0> self.max_flight_bytes: Optional[int] = None
<1> self.max_total_bytes: Optional[int] = None
<2>
<3> self._host_cid = host_cid
<4> self._pad_first_datagram = pad_first_datagram
<5> self._peer_cid = peer_cid
<6> self._peer_token = peer_token
<7> self._quic_logger = quic_logger
<8> self._spin_bit = spin_bit
<9> self._version = version
<10>
<11> # assembled datagrams and packets
<12> self._ack_eliciting = False
<13> self._datagrams: List[bytes] = []
<14> self._datagram_init = True
<15> self._packets: List[QuicSentPacket] = []
<16> self._flight_bytes = 0
<17> self._total_bytes = 0
<18>
<19> # current packet
<20> self._header_size = 0
<21> self._packet: Optional[QuicSentPacket] = None
<22> self._packet_crypto: Optional[CryptoPair] = None
<23> self._packet_long_header = False
<24> self._packet_number = packet_number
<25> self._packet_start = 0
<26> self._packet_type = 0
<27>
<28> self.buffer = Buffer(PACKET_MAX_SIZE)
<29> self._buffer_capacity = PACKET_MAX_SIZE
<30>
|
===========unchanged ref 0===========
at: aioquic._buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic.quic.crypto
CryptoPair()
at: aioquic.quic.logger
QuicLogger()
at: aioquic.quic.packet_builder
PACKET_MAX_SIZE = 1280
QuicSentPacket(epoch: Epoch, in_flight: bool, is_ack_eliciting: bool, is_crypto_packet: bool, packet_number: int, packet_type: int, sent_time: Optional[float]=None, sent_bytes: int=0, delivery_handlers: List[Tuple[QuicDeliveryHandler, Any]]=field(
default_factory=list
), quic_logger_frames: List[Dict]=field(default_factory=list))
at: aioquic.quic.packet_builder.QuicPacketBuilder._flush_current_datagram
self._datagram_init = True
self._flight_bytes += datagram_bytes
self._total_bytes += datagram_bytes
at: aioquic.quic.packet_builder.QuicPacketBuilder.end_packet
self._pad_first_datagram = False
self._packet_number += 1
self._packet = None
self.quic_logger_frames = None
at: aioquic.quic.packet_builder.QuicPacketBuilder.flush
self._datagrams = []
self._packets = []
at: aioquic.quic.packet_builder.QuicPacketBuilder.start_frame
self._ack_eliciting = True
at: aioquic.quic.packet_builder.QuicPacketBuilder.start_packet
self._ack_eliciting = False
self._datagram_init = False
self._header_size = header_size
===========unchanged ref 1===========
self._packet = QuicSentPacket(
epoch=epoch,
in_flight=False,
is_ack_eliciting=False,
is_crypto_packet=False,
packet_number=self._packet_number,
packet_type=packet_type,
)
self._packet_crypto = crypto
self._packet_long_header = packet_long_header
self._packet_start = packet_start
self._packet_type = packet_type
self.quic_logger_frames = self._packet.quic_logger_frames
at: typing
List = _alias(list, 1, inst=False, name='List')
Dict = _alias(dict, 2, inst=False, name='Dict')
===========changed ref 0===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_ping_frame(self) -> Dict:
+ return {"frame_type": "ping"}
- return {"frame_type": "PING"}
===========changed ref 1===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_padding_frame(self) -> Dict:
+ return {"frame_type": "padding"}
- return {"frame_type": "PADDING"}
===========changed ref 2===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_data_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_data", "maximum": str(maximum)}
- return {"frame_type": "MAX_DATA", "maximum": str(maximum)}
===========changed ref 3===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_streams_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_streams", "maximum": str(maximum)}
- return {"frame_type": "MAX_STREAMS", "maximum": str(maximum)}
===========changed ref 4===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_data_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "data_blocked", "limit": str(limit)}
- return {"frame_type": "DATA_BLOCKED", "limit": str(limit)}
===========changed ref 5===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_streams_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "streams_blocked", "limit": str(limit)}
- return {"frame_type": "STREAMS_BLOCKED", "limit": str(limit)}
===========changed ref 6===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_path_response_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "path_response"}
- return {"data": hexdump(data), "frame_type": "PATH_RESPONSE"}
===========changed ref 7===========
# module: aioquic.quic.logger
class QuicLogger:
def start_trace(self, is_client: bool) -> None:
+ self._vantage_point["type"] = "client" if is_client else "server"
- self._vantage_point["type"] = "CLIENT" if is_client else "SERVER"
===========changed ref 8===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_path_challenge_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "path_challenge"}
- return {"data": hexdump(data), "frame_type": "PATH_CHALLENGE"}
===========changed ref 9===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_retire_connection_id_frame(self, sequence_number: int) -> Dict:
return {
+ "frame_type": "retire_connection_id",
- "frame_type": "RETIRE_CONNECTION_ID",
"sequence_number": str(sequence_number),
}
===========changed ref 10===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_new_token_frame(self, token: bytes) -> Dict:
return {
+ "frame_type": "new_token",
- "frame_type": "NEW_TOKEN",
"length": str(len(token)),
"token": hexdump(token),
}
===========changed ref 11===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_stop_sending_frame(self, error_code: int, stream_id: int) -> Dict:
return {
+ "frame_type": "stop_sending",
- "frame_type": "STOP_SENDING",
"id": str(stream_id),
"error_code": error_code,
}
===========changed ref 12===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_reset_stream_frame(
self, error_code: int, final_size: int, stream_id: int
) -> Dict:
return {
"error_code": error_code,
"final_size": str(final_size),
+ "frame_type": "reset_stream",
- "frame_type": "RESET_STREAM",
}
===========changed ref 13===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_stream_data_frame(self, maximum: int, stream_id: int) -> Dict:
return {
+ "frame_type": "max_stream_data",
- "frame_type": "MAX_STREAM_DATA",
"id": str(stream_id),
"maximum": str(maximum),
}
===========changed ref 14===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_stream_data_blocked_frame(self, limit: int, stream_id: int) -> Dict:
return {
+ "frame_type": "stream_data_blocked",
- "frame_type": "STREAM_DATA_BLOCKED",
"limit": str(limit),
"stream_id": str(stream_id),
}
|
aioquic.quic.packet_builder/QuicPacketBuilder.start_packet
|
Modified
|
aiortc~aioquic
|
f89f264ca7ff9bf69a5ec2c3550bb0ffa67db2da
|
[qlog] switch to draft-01
|
# module: aioquic.quic.packet_builder
class QuicPacketBuilder:
def start_packet(self, packet_type: int, crypto: CryptoPair) -> None:
<0> """
<1> Starts a new packet.
<2> """
<3> buf = self.buffer
<4> self._ack_eliciting = False
<5>
<6> # if there is too little space remaining, start a new datagram
<7> # FIXME: the limit is arbitrary!
<8> packet_start = buf.tell()
<9> if self._buffer_capacity - packet_start < 128:
<10> self._flush_current_datagram()
<11> packet_start = 0
<12>
<13> # initialize datagram if needed
<14> if self._datagram_init:
<15> if self.max_flight_bytes is not None:
<16> remaining_flight_bytes = self.max_flight_bytes - self._flight_bytes
<17> if remaining_flight_bytes < self._buffer_capacity:
<18> self._buffer_capacity = remaining_flight_bytes
<19> if self.max_total_bytes is not None:
<20> remaining_total_bytes = self.max_total_bytes - self._total_bytes
<21> if remaining_total_bytes < self._buffer_capacity:
<22> self._buffer_capacity = remaining_total_bytes
<23> self._datagram_init = False
<24>
<25> # calculate header size
<26> packet_long_header = is_long_header(packet_type)
<27> if packet_long_header:
<28> header_size = 11 + len(self._peer_cid) + len(self._host_cid)
<29> if (packet_type & PACKET_TYPE_MASK) == PACKET_TYPE_INITIAL:
<30> token_length = len(self._peer_token)
<31> header_size += size_uint_var(token_length) + token_length
<32> else:
<33> header_size = 3 + len(self._peer_cid)
<34>
<35> # check we have enough space
<36> if packet_start + header_size >= self._buffer_capacity:
<37> raise QuicPacketBuilderStop
<38> </s>
|
===========below chunk 0===========
# module: aioquic.quic.packet_builder
class QuicPacketBuilder:
def start_packet(self, packet_type: int, crypto: CryptoPair) -> None:
# offset: 1
if packet_type == PACKET_TYPE_INITIAL:
epoch = Epoch.INITIAL
elif packet_type == PACKET_TYPE_HANDSHAKE:
epoch = Epoch.HANDSHAKE
else:
epoch = Epoch.ONE_RTT
self._header_size = header_size
self._packet = QuicSentPacket(
epoch=epoch,
in_flight=False,
is_ack_eliciting=False,
is_crypto_packet=False,
packet_number=self._packet_number,
packet_type=packet_type,
)
self._packet_crypto = crypto
self._packet_long_header = packet_long_header
self._packet_start = packet_start
self._packet_type = packet_type
buf.seek(self._packet_start + self._header_size)
===========unchanged ref 0===========
at: aioquic._buffer.Buffer
tell() -> int
at: aioquic.buffer
size_uint_var(value: int) -> int
at: aioquic.quic.crypto
CryptoPair()
at: aioquic.quic.packet
PACKET_TYPE_INITIAL = PACKET_LONG_HEADER | PACKET_FIXED_BIT | 0x00
PACKET_TYPE_HANDSHAKE = PACKET_LONG_HEADER | PACKET_FIXED_BIT | 0x20
PACKET_TYPE_MASK = 0xF0
is_long_header(first_byte: int) -> bool
at: aioquic.quic.packet_builder
QuicSentPacket(epoch: Epoch, in_flight: bool, is_ack_eliciting: bool, is_crypto_packet: bool, packet_number: int, packet_type: int, sent_time: Optional[float]=None, sent_bytes: int=0, delivery_handlers: List[Tuple[QuicDeliveryHandler, Any]]=field(
default_factory=list
), quic_logger_frames: List[Dict]=field(default_factory=list))
QuicPacketBuilderStop(*args: object)
at: aioquic.quic.packet_builder.QuicPacketBuilder
_flush_current_datagram() -> None
at: aioquic.quic.packet_builder.QuicPacketBuilder.__init__
self.max_flight_bytes: Optional[int] = None
self.max_total_bytes: Optional[int] = None
self.quic_logger_frames: Optional[List[Dict]] = None
self._host_cid = host_cid
self._peer_cid = peer_cid
self._peer_token = peer_token
self._ack_eliciting = False
self._datagram_init = True
self._flight_bytes = 0
self._total_bytes = 0
self._header_size = 0
self._packet: Optional[QuicSentPacket] = None
===========unchanged ref 1===========
self._packet_crypto: Optional[CryptoPair] = None
self._packet_long_header = False
self._packet_number = packet_number
self._packet_start = 0
self._packet_type = 0
self.buffer = Buffer(PACKET_MAX_SIZE)
self._buffer_capacity = PACKET_MAX_SIZE
at: aioquic.quic.packet_builder.QuicPacketBuilder._flush_current_datagram
self._datagram_init = True
self._flight_bytes += datagram_bytes
self._total_bytes += datagram_bytes
at: aioquic.quic.packet_builder.QuicPacketBuilder.end_packet
self._packet_number += 1
self._packet = None
self.quic_logger_frames = None
at: aioquic.quic.packet_builder.QuicPacketBuilder.start_frame
self._ack_eliciting = True
at: aioquic.quic.packet_builder.QuicSentPacket
epoch: Epoch
in_flight: bool
is_ack_eliciting: bool
is_crypto_packet: bool
packet_number: int
packet_type: int
sent_time: Optional[float] = None
sent_bytes: int = 0
delivery_handlers: List[Tuple[QuicDeliveryHandler, Any]] = field(
default_factory=list
)
quic_logger_frames: List[Dict] = field(default_factory=list)
at: aioquic.tls
Epoch()
===========changed ref 0===========
# module: aioquic.quic.packet_builder
class QuicPacketBuilder:
def __init__(
self,
*,
host_cid: bytes,
peer_cid: bytes,
version: int,
pad_first_datagram: bool = False,
packet_number: int = 0,
peer_token: bytes = b"",
quic_logger: Optional[QuicLogger] = None,
spin_bit: bool = False,
):
self.max_flight_bytes: Optional[int] = None
self.max_total_bytes: Optional[int] = None
+ self.quic_logger_frames: Optional[List[Dict]] = None
self._host_cid = host_cid
self._pad_first_datagram = pad_first_datagram
self._peer_cid = peer_cid
self._peer_token = peer_token
self._quic_logger = quic_logger
self._spin_bit = spin_bit
self._version = version
# assembled datagrams and packets
self._ack_eliciting = False
self._datagrams: List[bytes] = []
self._datagram_init = True
self._packets: List[QuicSentPacket] = []
self._flight_bytes = 0
self._total_bytes = 0
# current packet
self._header_size = 0
self._packet: Optional[QuicSentPacket] = None
self._packet_crypto: Optional[CryptoPair] = None
self._packet_long_header = False
self._packet_number = packet_number
self._packet_start = 0
self._packet_type = 0
self.buffer = Buffer(PACKET_MAX_SIZE)
self._buffer_capacity = PACKET_MAX_SIZE
===========changed ref 1===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_ping_frame(self) -> Dict:
+ return {"frame_type": "ping"}
- return {"frame_type": "PING"}
===========changed ref 2===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_padding_frame(self) -> Dict:
+ return {"frame_type": "padding"}
- return {"frame_type": "PADDING"}
===========changed ref 3===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_data_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_data", "maximum": str(maximum)}
- return {"frame_type": "MAX_DATA", "maximum": str(maximum)}
===========changed ref 4===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_streams_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_streams", "maximum": str(maximum)}
- return {"frame_type": "MAX_STREAMS", "maximum": str(maximum)}
===========changed ref 5===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_data_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "data_blocked", "limit": str(limit)}
- return {"frame_type": "DATA_BLOCKED", "limit": str(limit)}
|
|
aioquic.quic.packet_builder/QuicPacketBuilder.end_packet
|
Modified
|
aiortc~aioquic
|
f89f264ca7ff9bf69a5ec2c3550bb0ffa67db2da
|
[qlog] switch to draft-01
|
# module: aioquic.quic.packet_builder
class QuicPacketBuilder:
def end_packet(self) -> bool:
<0> """
<1> Ends the current packet.
<2>
<3> Returns `True` if the packet contains data, `False` otherwise.
<4> """
<5> buf = self.buffer
<6> empty = True
<7> packet_size = buf.tell() - self._packet_start
<8> if packet_size > self._header_size:
<9> empty = False
<10>
<11> # pad initial datagram
<12> if self._pad_first_datagram:
<13> if self.remaining_space:
<14> buf.push_bytes(bytes(self.remaining_space))
<15> packet_size = buf.tell() - self._packet_start
<16>
<17> # log frame
<18> if self._quic_logger is not None:
<19> self._packet.quic_logger_frames.append(
<20> self._quic_logger.encode_padding_frame()
<21> )
<22> self._pad_first_datagram = False
<23>
<24> # write header
<25> if self._packet_long_header:
<26> length = (
<27> packet_size
<28> - self._header_size
<29> + PACKET_NUMBER_SEND_SIZE
<30> + self._packet_crypto.aead_tag_size
<31> )
<32>
<33> buf.seek(self._packet_start)
<34> buf.push_uint8(self._packet_type | (PACKET_NUMBER_SEND_SIZE - 1))
<35> buf.push_uint32(self._version)
<36> buf.push_uint8(len(self._peer_cid))
<37> buf.push_bytes(self._peer_cid)
<38> buf.push_uint8(len(self._host_cid))
<39> buf.push_bytes(self._host_cid)
<40> if (self._packet_type & PACKET_TYPE_MASK) == PACKET_TYPE_INITIAL:
<41> buf.push_uint_var(len(self._peer_token))
<42> buf.push_bytes(self</s>
|
===========below chunk 0===========
# module: aioquic.quic.packet_builder
class QuicPacketBuilder:
def end_packet(self) -> bool:
# offset: 1
buf.push_uint16(length | 0x4000)
buf.push_uint16(self._packet_number & 0xFFFF)
else:
buf.seek(self._packet_start)
buf.push_uint8(
self._packet_type
| (self._spin_bit << 5)
| (self._packet_crypto.key_phase << 2)
| (PACKET_NUMBER_SEND_SIZE - 1)
)
buf.push_bytes(self._peer_cid)
buf.push_uint16(self._packet_number & 0xFFFF)
# check whether we need padding
padding_size = (
PACKET_NUMBER_MAX_SIZE
- PACKET_NUMBER_SEND_SIZE
+ self._header_size
- packet_size
)
if padding_size > 0:
buf.seek(self._packet_start + packet_size)
buf.push_bytes(bytes(padding_size))
packet_size += padding_size
# encrypt in place
plain = buf.data_slice(self._packet_start, self._packet_start + packet_size)
buf.seek(self._packet_start)
buf.push_bytes(
self._packet_crypto.encrypt_packet(
plain[0 : self._header_size],
plain[self._header_size : packet_size],
self._packet_number,
)
)
self._packet.sent_bytes = buf.tell() - self._packet_start
self._packets.append(self._packet)
# short header packets cannot be coallesced, we need a new datagram
if not self._packet_long_header:
self._flush_current_datagram()
self._packet_number += 1
else:
# "cancel" the packet
buf.seek(self._packet_start)
self._packet = None
return not</s>
===========below chunk 1===========
# module: aioquic.quic.packet_builder
class QuicPacketBuilder:
def end_packet(self) -> bool:
# offset: 2
<s> "cancel" the packet
buf.seek(self._packet_start)
self._packet = None
return not empty
===========unchanged ref 0===========
at: aioquic._buffer.Buffer
data_slice(start: int, end: int) -> bytes
seek(pos: int) -> None
tell() -> int
push_bytes(value: bytes) -> None
push_uint8(value: int) -> None
push_uint16(value: int) -> None
push_uint32(v: int) -> None
push_uint_var(value: int) -> None
at: aioquic.quic.crypto.CryptoPair
encrypt_packet(plain_header: bytes, plain_payload: bytes, packet_number: int) -> bytes
at: aioquic.quic.crypto.CryptoPair.__init__
self.aead_tag_size = 16
at: aioquic.quic.logger.QuicLogger
encode_padding_frame() -> Dict
at: aioquic.quic.packet
PACKET_TYPE_INITIAL = PACKET_LONG_HEADER | PACKET_FIXED_BIT | 0x00
PACKET_TYPE_MASK = 0xF0
PACKET_NUMBER_MAX_SIZE = 4
at: aioquic.quic.packet_builder
PACKET_NUMBER_SEND_SIZE = 2
at: aioquic.quic.packet_builder.QuicPacketBuilder
_flush_current_datagram() -> None
at: aioquic.quic.packet_builder.QuicPacketBuilder.__init__
self._host_cid = host_cid
self._pad_first_datagram = pad_first_datagram
self._peer_cid = peer_cid
self._peer_token = peer_token
self._quic_logger = quic_logger
self._spin_bit = spin_bit
self._version = version
self._packets: List[QuicSentPacket] = []
self._header_size = 0
self._packet: Optional[QuicSentPacket] = None
self._packet_crypto: Optional[CryptoPair] = None
self._packet_long_header = False
===========unchanged ref 1===========
self._packet_number = packet_number
self._packet_start = 0
self._packet_type = 0
self.buffer = Buffer(PACKET_MAX_SIZE)
at: aioquic.quic.packet_builder.QuicPacketBuilder.flush
self._packets = []
at: aioquic.quic.packet_builder.QuicPacketBuilder.start_packet
buf = self.buffer
self._header_size = header_size
self._packet = QuicSentPacket(
epoch=epoch,
in_flight=False,
is_ack_eliciting=False,
is_crypto_packet=False,
packet_number=self._packet_number,
packet_type=packet_type,
)
self._packet_crypto = crypto
self._packet_long_header = packet_long_header
self._packet_start = packet_start
self._packet_type = packet_type
at: aioquic.quic.packet_builder.QuicSentPacket
sent_bytes: int = 0
quic_logger_frames: List[Dict] = field(default_factory=list)
===========changed ref 0===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_padding_frame(self) -> Dict:
+ return {"frame_type": "padding"}
- return {"frame_type": "PADDING"}
===========changed ref 1===========
# module: aioquic.quic.packet_builder
class QuicPacketBuilder:
def __init__(
self,
*,
host_cid: bytes,
peer_cid: bytes,
version: int,
pad_first_datagram: bool = False,
packet_number: int = 0,
peer_token: bytes = b"",
quic_logger: Optional[QuicLogger] = None,
spin_bit: bool = False,
):
self.max_flight_bytes: Optional[int] = None
self.max_total_bytes: Optional[int] = None
+ self.quic_logger_frames: Optional[List[Dict]] = None
self._host_cid = host_cid
self._pad_first_datagram = pad_first_datagram
self._peer_cid = peer_cid
self._peer_token = peer_token
self._quic_logger = quic_logger
self._spin_bit = spin_bit
self._version = version
# assembled datagrams and packets
self._ack_eliciting = False
self._datagrams: List[bytes] = []
self._datagram_init = True
self._packets: List[QuicSentPacket] = []
self._flight_bytes = 0
self._total_bytes = 0
# current packet
self._header_size = 0
self._packet: Optional[QuicSentPacket] = None
self._packet_crypto: Optional[CryptoPair] = None
self._packet_long_header = False
self._packet_number = packet_number
self._packet_start = 0
self._packet_type = 0
self.buffer = Buffer(PACKET_MAX_SIZE)
self._buffer_capacity = PACKET_MAX_SIZE
|
|
aioquic.quic.recovery/QuicPacketRecovery.on_ack_received
|
Modified
|
aiortc~aioquic
|
f89f264ca7ff9bf69a5ec2c3550bb0ffa67db2da
|
[qlog] switch to draft-01
|
# module: aioquic.quic.recovery
class QuicPacketRecovery:
def on_ack_received(
self,
space: QuicPacketSpace,
ack_rangeset: RangeSet,
ack_delay: float,
now: float,
) -> None:
<0> """
<1> Update metrics as the result of an ACK being received.
<2> """
<3> is_ack_eliciting = False
<4> largest_acked = ack_rangeset.bounds().stop - 1
<5> largest_newly_acked = None
<6> largest_sent_time = None
<7>
<8> if largest_acked > space.largest_acked_packet:
<9> space.largest_acked_packet = largest_acked
<10>
<11> for packet_number in sorted(space.sent_packets.keys()):
<12> if packet_number > largest_acked:
<13> break
<14> if packet_number in ack_rangeset:
<15> # remove packet and update counters
<16> packet = space.sent_packets.pop(packet_number)
<17> if packet.is_ack_eliciting:
<18> is_ack_eliciting = True
<19> space.ack_eliciting_in_flight -= 1
<20> if packet.in_flight:
<21> self.on_packet_acked(packet)
<22> largest_newly_acked = packet_number
<23> largest_sent_time = packet.sent_time
<24>
<25> # trigger callbacks
<26> for handler, args in packet.delivery_handlers:
<27> handler(QuicDeliveryState.ACKED, *args)
<28>
<29> # nothing to do if there are no newly acked packets
<30> if largest_newly_acked is None:
<31> return
<32>
<33> if largest_acked == largest_newly_acked and is_ack_eliciting:
<34> latest_rtt = now - largest_sent_time
<35>
<36> # limit ACK delay to max_ack_delay
<37> ack_delay = min(ack_delay, self.max_ack_delay)
<38> </s>
|
===========below chunk 0===========
# module: aioquic.quic.recovery
class QuicPacketRecovery:
def on_ack_received(
self,
space: QuicPacketSpace,
ack_rangeset: RangeSet,
ack_delay: float,
now: float,
) -> None:
# offset: 1
self._rtt_latest = max(latest_rtt, 0.001)
if self._rtt_latest < self._rtt_min:
self._rtt_min = self._rtt_latest
if self._rtt_latest > self._rtt_min + ack_delay:
self._rtt_latest -= ack_delay
if not self._rtt_initialized:
self._rtt_initialized = True
self._rtt_variance = latest_rtt / 2
self._rtt_smoothed = latest_rtt
else:
self._rtt_variance = 3 / 4 * self._rtt_variance + 1 / 4 * abs(
self._rtt_min - self._rtt_latest
)
self._rtt_smoothed = (
7 / 8 * self._rtt_smoothed + 1 / 8 * self._rtt_latest
)
if self._quic_logger is not None:
self._quic_logger.log_event(
category="RECOVERY",
event="METRIC_UPDATE",
data={
"latest_rtt": int(self._rtt_latest * 1000),
"min_rtt": int(self._rtt_min * 1000),
"smoothed_rtt": int(self._rtt_smoothed * 1000),
"rtt_variance": int(self._rtt_variance * 1000),
},
)
self.detect_loss(space, now=now)
self._pto_count = 0
===========unchanged ref 0===========
at: aioquic.quic.logger.QuicLogger
log_event(*, category: str, event: str, data: Dict) -> None
at: aioquic.quic.packet_builder
QuicDeliveryState()
at: aioquic.quic.packet_builder.QuicSentPacket
epoch: Epoch
in_flight: bool
is_ack_eliciting: bool
is_crypto_packet: bool
packet_number: int
packet_type: int
sent_time: Optional[float] = None
sent_bytes: int = 0
delivery_handlers: List[Tuple[QuicDeliveryHandler, Any]] = field(
default_factory=list
)
quic_logger_frames: List[Dict] = field(default_factory=list)
at: aioquic.quic.rangeset
RangeSet(ranges: Iterable[range]=[])
at: aioquic.quic.rangeset.RangeSet
bounds() -> range
at: aioquic.quic.recovery
QuicPacketSpace()
at: aioquic.quic.recovery.QuicPacketRecovery
detect_loss(space: QuicPacketSpace, now: float) -> None
on_packet_acked(packet: QuicSentPacket) -> None
at: aioquic.quic.recovery.QuicPacketRecovery.__init__
self.max_ack_delay = 0.025
self._quic_logger = quic_logger
self._pto_count = 0
self._rtt_initialized = False
self._rtt_latest = 0.0
self._rtt_min = math.inf
self._rtt_smoothed = 0.0
self._rtt_variance = 0.0
at: aioquic.quic.recovery.QuicPacketRecovery.on_loss_detection_timeout
self._pto_count += 1
===========unchanged ref 1===========
at: aioquic.quic.recovery.QuicPacketSpace.__init__
self.ack_eliciting_in_flight = 0
self.largest_acked_packet = 0
self.sent_packets: Dict[int, QuicSentPacket] = {}
at: typing.MutableMapping
pop(key: _KT) -> _VT
pop(key: _KT, default: Union[_VT, _T]=...) -> Union[_VT, _T]
===========changed ref 0===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_ping_frame(self) -> Dict:
+ return {"frame_type": "ping"}
- return {"frame_type": "PING"}
===========changed ref 1===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_padding_frame(self) -> Dict:
+ return {"frame_type": "padding"}
- return {"frame_type": "PADDING"}
===========changed ref 2===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_data_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_data", "maximum": str(maximum)}
- return {"frame_type": "MAX_DATA", "maximum": str(maximum)}
===========changed ref 3===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_streams_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_streams", "maximum": str(maximum)}
- return {"frame_type": "MAX_STREAMS", "maximum": str(maximum)}
===========changed ref 4===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_data_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "data_blocked", "limit": str(limit)}
- return {"frame_type": "DATA_BLOCKED", "limit": str(limit)}
===========changed ref 5===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_streams_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "streams_blocked", "limit": str(limit)}
- return {"frame_type": "STREAMS_BLOCKED", "limit": str(limit)}
===========changed ref 6===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_path_response_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "path_response"}
- return {"data": hexdump(data), "frame_type": "PATH_RESPONSE"}
===========changed ref 7===========
# module: aioquic.quic.logger
class QuicLogger:
def start_trace(self, is_client: bool) -> None:
+ self._vantage_point["type"] = "client" if is_client else "server"
- self._vantage_point["type"] = "CLIENT" if is_client else "SERVER"
===========changed ref 8===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_path_challenge_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "path_challenge"}
- return {"data": hexdump(data), "frame_type": "PATH_CHALLENGE"}
===========changed ref 9===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_retire_connection_id_frame(self, sequence_number: int) -> Dict:
return {
+ "frame_type": "retire_connection_id",
- "frame_type": "RETIRE_CONNECTION_ID",
"sequence_number": str(sequence_number),
}
===========changed ref 10===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_new_token_frame(self, token: bytes) -> Dict:
return {
+ "frame_type": "new_token",
- "frame_type": "NEW_TOKEN",
"length": str(len(token)),
"token": hexdump(token),
}
|
|
aioquic.quic.recovery/QuicPacketRecovery.on_packet_lost
|
Modified
|
aiortc~aioquic
|
f89f264ca7ff9bf69a5ec2c3550bb0ffa67db2da
|
[qlog] switch to draft-01
|
<9>:<add> category="recovery",
<del> category="RECOVERY",
<10>:<add> event="packet_lost",
<del> event="PACKET_LOST",
|
# module: aioquic.quic.recovery
class QuicPacketRecovery:
def on_packet_lost(self, packet: QuicSentPacket, space: QuicPacketSpace) -> None:
<0> del space.sent_packets[packet.packet_number]
<1>
<2> if packet.is_ack_eliciting:
<3> space.ack_eliciting_in_flight -= 1
<4> if packet.in_flight:
<5> self.bytes_in_flight -= packet.sent_bytes
<6>
<7> if self._quic_logger is not None:
<8> self._quic_logger.log_event(
<9> category="RECOVERY",
<10> event="PACKET_LOST",
<11> data={
<12> "type": self._quic_logger.packet_type(packet.packet_type),
<13> "packet_number": str(packet.packet_number),
<14> },
<15> )
<16> self._log_metric_update()
<17>
<18> # trigger callbacks
<19> for handler, args in packet.delivery_handlers:
<20> handler(QuicDeliveryState.LOST, *args)
<21>
|
===========unchanged ref 0===========
at: aioquic.quic.logger.QuicLogger
log_event(*, category: str, event: str, data: Dict) -> None
packet_type(packet_type: int) -> str
at: aioquic.quic.packet_builder
QuicDeliveryState()
QuicSentPacket(epoch: Epoch, in_flight: bool, is_ack_eliciting: bool, is_crypto_packet: bool, packet_number: int, packet_type: int, sent_time: Optional[float]=None, sent_bytes: int=0, delivery_handlers: List[Tuple[QuicDeliveryHandler, Any]]=field(
default_factory=list
), quic_logger_frames: List[Dict]=field(default_factory=list))
at: aioquic.quic.packet_builder.QuicSentPacket
in_flight: bool
is_ack_eliciting: bool
packet_number: int
packet_type: int
sent_bytes: int = 0
delivery_handlers: List[Tuple[QuicDeliveryHandler, Any]] = field(
default_factory=list
)
at: aioquic.quic.recovery
QuicPacketSpace()
at: aioquic.quic.recovery.QuicPacketRecovery
_log_metric_update(self) -> None
_log_metric_update() -> None
at: aioquic.quic.recovery.QuicPacketRecovery.__init__
self._quic_logger = quic_logger
self.bytes_in_flight = 0
at: aioquic.quic.recovery.QuicPacketRecovery.on_packet_acked
self.bytes_in_flight -= packet.sent_bytes
at: aioquic.quic.recovery.QuicPacketRecovery.on_packet_expired
self.bytes_in_flight -= packet.sent_bytes
at: aioquic.quic.recovery.QuicPacketRecovery.on_packet_sent
self.bytes_in_flight += packet.sent_bytes
===========unchanged ref 1===========
at: aioquic.quic.recovery.QuicPacketSpace.__init__
self.ack_eliciting_in_flight = 0
self.sent_packets: Dict[int, QuicSentPacket] = {}
===========changed ref 0===========
# module: aioquic.quic.recovery
class QuicPacketRecovery:
def on_ack_received(
self,
space: QuicPacketSpace,
ack_rangeset: RangeSet,
ack_delay: float,
now: float,
) -> None:
"""
Update metrics as the result of an ACK being received.
"""
is_ack_eliciting = False
largest_acked = ack_rangeset.bounds().stop - 1
largest_newly_acked = None
largest_sent_time = None
if largest_acked > space.largest_acked_packet:
space.largest_acked_packet = largest_acked
for packet_number in sorted(space.sent_packets.keys()):
if packet_number > largest_acked:
break
if packet_number in ack_rangeset:
# remove packet and update counters
packet = space.sent_packets.pop(packet_number)
if packet.is_ack_eliciting:
is_ack_eliciting = True
space.ack_eliciting_in_flight -= 1
if packet.in_flight:
self.on_packet_acked(packet)
largest_newly_acked = packet_number
largest_sent_time = packet.sent_time
# trigger callbacks
for handler, args in packet.delivery_handlers:
handler(QuicDeliveryState.ACKED, *args)
# nothing to do if there are no newly acked packets
if largest_newly_acked is None:
return
if largest_acked == largest_newly_acked and is_ack_eliciting:
latest_rtt = now - largest_sent_time
# limit ACK delay to max_ack_delay
ack_delay = min(ack_delay, self.max_ack_delay)
# update RTT estimate, which cannot be < 1 ms
self._rtt_latest = max(latest_rtt, 0.001)
if self._</s>
===========changed ref 1===========
# module: aioquic.quic.recovery
class QuicPacketRecovery:
def on_ack_received(
self,
space: QuicPacketSpace,
ack_rangeset: RangeSet,
ack_delay: float,
now: float,
) -> None:
# offset: 1
<s> cannot be < 1 ms
self._rtt_latest = max(latest_rtt, 0.001)
if self._rtt_latest < self._rtt_min:
self._rtt_min = self._rtt_latest
if self._rtt_latest > self._rtt_min + ack_delay:
self._rtt_latest -= ack_delay
if not self._rtt_initialized:
self._rtt_initialized = True
self._rtt_variance = latest_rtt / 2
self._rtt_smoothed = latest_rtt
else:
self._rtt_variance = 3 / 4 * self._rtt_variance + 1 / 4 * abs(
self._rtt_min - self._rtt_latest
)
self._rtt_smoothed = (
7 / 8 * self._rtt_smoothed + 1 / 8 * self._rtt_latest
)
if self._quic_logger is not None:
self._quic_logger.log_event(
+ category="recovery",
- category="RECOVERY",
+ event="metric_update",
- event="METRIC_UPDATE",
data={
"latest_rtt": int(self._rtt_latest * 1000),
"min_rtt": int(self._rtt_min * 1000),
"smoothed_rtt": int(self._rtt_smoothed * 1000),
"rtt_variance": int(self._rtt_variance * 1000),
},
)
self.detect_loss(space, now=now)
self._pto_count = 0
===========changed ref 2===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_ping_frame(self) -> Dict:
+ return {"frame_type": "ping"}
- return {"frame_type": "PING"}
===========changed ref 3===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_padding_frame(self) -> Dict:
+ return {"frame_type": "padding"}
- return {"frame_type": "PADDING"}
===========changed ref 4===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_data_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_data", "maximum": str(maximum)}
- return {"frame_type": "MAX_DATA", "maximum": str(maximum)}
===========changed ref 5===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_streams_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_streams", "maximum": str(maximum)}
- return {"frame_type": "MAX_STREAMS", "maximum": str(maximum)}
===========changed ref 6===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_data_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "data_blocked", "limit": str(limit)}
- return {"frame_type": "DATA_BLOCKED", "limit": str(limit)}
===========changed ref 7===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_streams_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "streams_blocked", "limit": str(limit)}
- return {"frame_type": "STREAMS_BLOCKED", "limit": str(limit)}
|
aioquic.quic.recovery/QuicPacketRecovery._log_metric_update
|
Modified
|
aiortc~aioquic
|
f89f264ca7ff9bf69a5ec2c3550bb0ffa67db2da
|
[qlog] switch to draft-01
|
<5>:<add> category="recovery", event="metric_update", data=data
<del> category="RECOVERY", event="METRIC_UPDATE", data=data
|
# module: aioquic.quic.recovery
class QuicPacketRecovery:
# TODO : collapse congestion window if persistent congestion
def _log_metric_update(self) -> None:
<0> data = {"bytes_in_flight": self.bytes_in_flight, "cwnd": self.congestion_window}
<1> if self._ssthresh is not None:
<2> data["ssthresh"] = self._ssthresh
<3>
<4> self._quic_logger.log_event(
<5> category="RECOVERY", event="METRIC_UPDATE", data=data
<6> )
<7>
|
===========unchanged ref 0===========
at: aioquic.quic.logger.QuicLogger
log_event(*, category: str, event: str, data: Dict) -> None
at: aioquic.quic.recovery.QuicPacketRecovery.__init__
self._quic_logger = quic_logger
self.bytes_in_flight = 0
self.congestion_window = K_INITIAL_WINDOW
self._ssthresh: Optional[int] = None
at: aioquic.quic.recovery.QuicPacketRecovery.on_packet_acked
self.bytes_in_flight -= packet.sent_bytes
self.congestion_window += (
K_MAX_DATAGRAM_SIZE * packet.sent_bytes // self.congestion_window
)
self.congestion_window += packet.sent_bytes
at: aioquic.quic.recovery.QuicPacketRecovery.on_packet_expired
self.bytes_in_flight -= packet.sent_bytes
at: aioquic.quic.recovery.QuicPacketRecovery.on_packet_lost
self.bytes_in_flight -= packet.sent_bytes
at: aioquic.quic.recovery.QuicPacketRecovery.on_packet_sent
self.bytes_in_flight += packet.sent_bytes
at: aioquic.quic.recovery.QuicPacketRecovery.on_packets_lost
self.congestion_window = max(
int(self.congestion_window * K_LOSS_REDUCTION_FACTOR), K_MINIMUM_WINDOW
)
self._ssthresh = self.congestion_window
===========changed ref 0===========
# module: aioquic.quic.recovery
class QuicPacketRecovery:
def on_packet_lost(self, packet: QuicSentPacket, space: QuicPacketSpace) -> None:
del space.sent_packets[packet.packet_number]
if packet.is_ack_eliciting:
space.ack_eliciting_in_flight -= 1
if packet.in_flight:
self.bytes_in_flight -= packet.sent_bytes
if self._quic_logger is not None:
self._quic_logger.log_event(
+ category="recovery",
- category="RECOVERY",
+ event="packet_lost",
- event="PACKET_LOST",
data={
"type": self._quic_logger.packet_type(packet.packet_type),
"packet_number": str(packet.packet_number),
},
)
self._log_metric_update()
# trigger callbacks
for handler, args in packet.delivery_handlers:
handler(QuicDeliveryState.LOST, *args)
===========changed ref 1===========
# module: aioquic.quic.recovery
class QuicPacketRecovery:
def on_ack_received(
self,
space: QuicPacketSpace,
ack_rangeset: RangeSet,
ack_delay: float,
now: float,
) -> None:
"""
Update metrics as the result of an ACK being received.
"""
is_ack_eliciting = False
largest_acked = ack_rangeset.bounds().stop - 1
largest_newly_acked = None
largest_sent_time = None
if largest_acked > space.largest_acked_packet:
space.largest_acked_packet = largest_acked
for packet_number in sorted(space.sent_packets.keys()):
if packet_number > largest_acked:
break
if packet_number in ack_rangeset:
# remove packet and update counters
packet = space.sent_packets.pop(packet_number)
if packet.is_ack_eliciting:
is_ack_eliciting = True
space.ack_eliciting_in_flight -= 1
if packet.in_flight:
self.on_packet_acked(packet)
largest_newly_acked = packet_number
largest_sent_time = packet.sent_time
# trigger callbacks
for handler, args in packet.delivery_handlers:
handler(QuicDeliveryState.ACKED, *args)
# nothing to do if there are no newly acked packets
if largest_newly_acked is None:
return
if largest_acked == largest_newly_acked and is_ack_eliciting:
latest_rtt = now - largest_sent_time
# limit ACK delay to max_ack_delay
ack_delay = min(ack_delay, self.max_ack_delay)
# update RTT estimate, which cannot be < 1 ms
self._rtt_latest = max(latest_rtt, 0.001)
if self._</s>
===========changed ref 2===========
# module: aioquic.quic.recovery
class QuicPacketRecovery:
def on_ack_received(
self,
space: QuicPacketSpace,
ack_rangeset: RangeSet,
ack_delay: float,
now: float,
) -> None:
# offset: 1
<s> cannot be < 1 ms
self._rtt_latest = max(latest_rtt, 0.001)
if self._rtt_latest < self._rtt_min:
self._rtt_min = self._rtt_latest
if self._rtt_latest > self._rtt_min + ack_delay:
self._rtt_latest -= ack_delay
if not self._rtt_initialized:
self._rtt_initialized = True
self._rtt_variance = latest_rtt / 2
self._rtt_smoothed = latest_rtt
else:
self._rtt_variance = 3 / 4 * self._rtt_variance + 1 / 4 * abs(
self._rtt_min - self._rtt_latest
)
self._rtt_smoothed = (
7 / 8 * self._rtt_smoothed + 1 / 8 * self._rtt_latest
)
if self._quic_logger is not None:
self._quic_logger.log_event(
+ category="recovery",
- category="RECOVERY",
+ event="metric_update",
- event="METRIC_UPDATE",
data={
"latest_rtt": int(self._rtt_latest * 1000),
"min_rtt": int(self._rtt_min * 1000),
"smoothed_rtt": int(self._rtt_smoothed * 1000),
"rtt_variance": int(self._rtt_variance * 1000),
},
)
self.detect_loss(space, now=now)
self._pto_count = 0
===========changed ref 3===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_ping_frame(self) -> Dict:
+ return {"frame_type": "ping"}
- return {"frame_type": "PING"}
===========changed ref 4===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_padding_frame(self) -> Dict:
+ return {"frame_type": "padding"}
- return {"frame_type": "PADDING"}
===========changed ref 5===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_data_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_data", "maximum": str(maximum)}
- return {"frame_type": "MAX_DATA", "maximum": str(maximum)}
===========changed ref 6===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_streams_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_streams", "maximum": str(maximum)}
- return {"frame_type": "MAX_STREAMS", "maximum": str(maximum)}
|
aioquic.quic.connection/QuicConnection.datagrams_to_send
|
Modified
|
aiortc~aioquic
|
f89f264ca7ff9bf69a5ec2c3550bb0ffa67db2da
|
[qlog] switch to draft-01
|
# module: aioquic.quic.connection
class QuicConnection:
def datagrams_to_send(self, now: float) -> List[Tuple[bytes, NetworkAddress]]:
<0> """
<1> Return a list of `(data, addr)` tuples of datagrams which need to be
<2> sent, and the network address to which they need to be sent.
<3>
<4> :param now: The current time.
<5> """
<6> network_path = self._network_paths[0]
<7>
<8> if self._state in END_STATES:
<9> return []
<10>
<11> # build datagrams
<12> builder = QuicPacketBuilder(
<13> host_cid=self.host_cid,
<14> packet_number=self._packet_number,
<15> pad_first_datagram=(
<16> self._is_client and self._state == QuicConnectionState.FIRSTFLIGHT
<17> ),
<18> peer_cid=self._peer_cid,
<19> peer_token=self._peer_token,
<20> quic_logger=self._quic_logger,
<21> spin_bit=self._spin_bit,
<22> version=self._version,
<23> )
<24> if self._close_pending:
<25> for epoch, packet_type in (
<26> (tls.Epoch.ONE_RTT, PACKET_TYPE_ONE_RTT),
<27> (tls.Epoch.HANDSHAKE, PACKET_TYPE_HANDSHAKE),
<28> (tls.Epoch.INITIAL, PACKET_TYPE_INITIAL),
<29> ):
<30> crypto = self._cryptos[epoch]
<31> if crypto.send.is_valid():
<32> builder.start_packet(packet_type, crypto)
<33> self._write_close_frame(
<34> builder=builder,
<35> error_code=self._close_event.error_code,
<36> frame_type=self._close_event.frame_type,
<37> reason_phrase=self._close_event.reason_phrase,
<38> )
<39> builder.end_packet()
<40> self._close_pending = False
<41> break</s>
|
===========below chunk 0===========
# module: aioquic.quic.connection
class QuicConnection:
def datagrams_to_send(self, now: float) -> List[Tuple[bytes, NetworkAddress]]:
# offset: 1
else:
# congestion control
builder.max_flight_bytes = (
self._loss.congestion_window - self._loss.bytes_in_flight
)
if self._probe_pending and builder.max_flight_bytes < PACKET_MAX_SIZE:
builder.max_flight_bytes = PACKET_MAX_SIZE
# limit data on un-validated network paths
if not network_path.is_validated:
builder.max_total_bytes = (
network_path.bytes_received * 3 - network_path.bytes_sent
)
try:
if not self._handshake_confirmed:
for epoch in [tls.Epoch.INITIAL, tls.Epoch.HANDSHAKE]:
self._write_handshake(builder, epoch)
self._write_application(builder, network_path, now)
except QuicPacketBuilderStop:
pass
datagrams, packets = builder.flush()
if datagrams:
self._packet_number = builder.packet_number
# register packets
sent_handshake = False
for packet in packets:
packet.sent_time = now
self._loss.on_packet_sent(
packet=packet, space=self._spaces[packet.epoch]
)
if packet.epoch == tls.Epoch.HANDSHAKE:
sent_handshake = True
# log packet
if self._quic_logger is not None:
self._quic_logger.log_event(
category="TRANSPORT",
event="PACKET_SENT",
data={
"packet_type": self._quic_logger.packet_type(
packet.packet_type
),
"header": {
"packet_number": str(packet.packet_number),
"packet_size": packet.sent_bytes,
"scid":</s>
===========below chunk 1===========
# module: aioquic.quic.connection
class QuicConnection:
def datagrams_to_send(self, now: float) -> List[Tuple[bytes, NetworkAddress]]:
# offset: 2
<s>_number": str(packet.packet_number),
"packet_size": packet.sent_bytes,
"scid": dump_cid(self.host_cid)
if is_long_header(packet.packet_type)
else "",
"dcid": dump_cid(self._peer_cid),
},
"frames": packet.quic_logger_frames,
},
)
# check if we can discard initial keys
if sent_handshake and self._is_client:
self._discard_epoch(tls.Epoch.INITIAL)
# return datagrams to send and the destination network address
ret = []
for datagram in datagrams:
byte_length = len(datagram)
network_path.bytes_sent += byte_length
ret.append((datagram, network_path.addr))
if self._quic_logger is not None:
self._quic_logger.log_event(
category="TRANSPORT",
event="DATAGRAM_SENT",
data={"byte_length": byte_length, "count": 1},
)
return ret
===========unchanged ref 0===========
at: aioquic.quic.connection
NetworkAddress = Any
dump_cid(cid: bytes) -> str
QuicConnectionState()
END_STATES = frozenset(
[
QuicConnectionState.CLOSING,
QuicConnectionState.DRAINING,
QuicConnectionState.TERMINATED,
]
)
at: aioquic.quic.connection.QuicConnection
_close_begin(is_initiator: bool, now: float) -> None
_write_close_frame(self, builder: QuicPacketBuilder, error_code: int, frame_type: Optional[int], reason_phrase: str) -> None
_write_close_frame(builder: QuicPacketBuilder, error_code: int, frame_type: Optional[int], reason_phrase: str) -> None
at: aioquic.quic.connection.QuicConnection.__init__
self._quic_logger = configuration.quic_logger
self._is_client = configuration.is_client
self._close_event: Optional[events.ConnectionTerminated] = None
self._cryptos: Dict[tls.Epoch, CryptoPair] = {}
self.host_cid = self._host_cids[0].cid
self._loss = QuicPacketRecovery(
is_client_without_1rtt=self._is_client,
quic_logger=self._quic_logger,
send_probe=self._send_probe,
)
self._network_paths: List[QuicNetworkPath] = []
self._packet_number = 0
self._peer_cid = os.urandom(8)
self._peer_token = b""
self._spin_bit = False
self._state = QuicConnectionState.FIRSTFLIGHT
self._version: Optional[int] = None
self._close_pending = False
self._probe_pending = False
===========unchanged ref 1===========
at: aioquic.quic.connection.QuicConnection._handle_connection_close_frame
self._close_event = events.ConnectionTerminated(
error_code=error_code, frame_type=frame_type, reason_phrase=reason_phrase
)
at: aioquic.quic.connection.QuicConnection._initialize
self._cryptos = {
tls.Epoch.INITIAL: CryptoPair(),
tls.Epoch.ZERO_RTT: CryptoPair(),
tls.Epoch.HANDSHAKE: CryptoPair(),
tls.Epoch.ONE_RTT: CryptoPair(),
}
self._packet_number = 0
at: aioquic.quic.connection.QuicConnection._send_probe
self._probe_pending = True
at: aioquic.quic.connection.QuicConnection._set_state
self._state = state
at: aioquic.quic.connection.QuicConnection._write_application
self._probe_pending = False
at: aioquic.quic.connection.QuicConnection._write_handshake
self._probe_pending = False
at: aioquic.quic.connection.QuicConnection.change_connection_id
self._peer_cid = connection_id.cid
at: aioquic.quic.connection.QuicConnection.close
self._close_event = events.ConnectionTerminated(
error_code=error_code,
frame_type=frame_type,
reason_phrase=reason_phrase,
)
self._close_pending = True
at: aioquic.quic.connection.QuicConnection.connect
self._network_paths = [QuicNetworkPath(addr, is_validated=True)]
self._version = self._configuration.supported_versions[0]
at: aioquic.quic.connection.QuicConnection.handle_timer
self._close_event = events.ConnectionTerminated(
error_code=QuicErrorCode.INTERNAL_ERROR,
frame_type=None,
reason_phrase="Idle timeout",
)
|
|
aioquic.quic.connection/QuicConnection._write_application
|
Modified
|
aiortc~aioquic
|
f89f264ca7ff9bf69a5ec2c3550bb0ffa67db2da
|
[qlog] switch to draft-01
|
<37>:<add> builder.quic_logger_frames.append(
<del> builder._packet.quic_logger_frames.append(
|
# module: aioquic.quic.connection
class QuicConnection:
def _write_application(
self, builder: QuicPacketBuilder, network_path: QuicNetworkPath, now: float
) -> None:
<0> crypto_stream: Optional[QuicStream] = None
<1> if self._cryptos[tls.Epoch.ONE_RTT].send.is_valid():
<2> crypto = self._cryptos[tls.Epoch.ONE_RTT]
<3> crypto_stream = self._crypto_streams[tls.Epoch.ONE_RTT]
<4> packet_type = PACKET_TYPE_ONE_RTT
<5> elif self._cryptos[tls.Epoch.ZERO_RTT].send.is_valid():
<6> crypto = self._cryptos[tls.Epoch.ZERO_RTT]
<7> packet_type = PACKET_TYPE_ZERO_RTT
<8> else:
<9> return
<10> space = self._spaces[tls.Epoch.ONE_RTT]
<11>
<12> buf = builder.buffer
<13>
<14> while True:
<15> # write header
<16> builder.start_packet(packet_type, crypto)
<17>
<18> if self._handshake_complete:
<19> # ACK
<20> if space.ack_at is not None and space.ack_at <= now:
<21> self._write_ack_frame(builder=builder, space=space)
<22>
<23> # PATH CHALLENGE
<24> if (
<25> not network_path.is_validated
<26> and network_path.local_challenge is None
<27> ):
<28> self._logger.info(
<29> "Network path %s sending challenge", network_path.addr
<30> )
<31> network_path.local_challenge = os.urandom(8)
<32> builder.start_frame(QuicFrameType.PATH_CHALLENGE)
<33> buf.push_bytes(network_path.local_challenge)
<34>
<35> # log frame
<36> if self._quic_logger is not None:
<37> builder._packet.quic_logger_frames.append(
<38> self._quic_logger</s>
|
===========below chunk 0===========
# module: aioquic.quic.connection
class QuicConnection:
def _write_application(
self, builder: QuicPacketBuilder, network_path: QuicNetworkPath, now: float
) -> None:
# offset: 1
data=network_path.local_challenge
)
)
# PATH RESPONSE
if network_path.remote_challenge is not None:
challenge = network_path.remote_challenge
builder.start_frame(QuicFrameType.PATH_RESPONSE)
buf.push_bytes(challenge)
network_path.remote_challenge = None
# log frame
if self._quic_logger is not None:
builder._packet.quic_logger_frames.append(
self._quic_logger.encode_path_response_frame(data=challenge)
)
# NEW_CONNECTION_ID
for connection_id in self._host_cids:
if not connection_id.was_sent:
self._write_new_connection_id_frame(
builder=builder, connection_id=connection_id
)
# RETIRE_CONNECTION_ID
while self._retire_connection_ids:
sequence_number = self._retire_connection_ids.pop(0)
self._write_retire_connection_id_frame(
builder=builder, sequence_number=sequence_number
)
# STREAMS_BLOCKED
if self._streams_blocked_pending:
if self._streams_blocked_bidi:
self._write_streams_blocked_frame(
builder=builder,
frame_type=QuicFrameType.STREAMS_BLOCKED_BIDI,
limit=self._remote_max_streams_bidi,
)
if self._streams_blocked_uni:
self._write_streams_blocked_frame(
builder=builder,
frame_type=QuicFrameType.STREAMS_BLOCKED_UNI,
limit=self._remote_max_streams_uni,
)
self._streams_blocked_pending = False
#</s>
===========below chunk 1===========
# module: aioquic.quic.connection
class QuicConnection:
def _write_application(
self, builder: QuicPacketBuilder, network_path: QuicNetworkPath, now: float
) -> None:
# offset: 2
<s>=self._remote_max_streams_uni,
)
self._streams_blocked_pending = False
# connection-level limits
self._write_connection_limits(builder=builder, space=space)
# stream-level limits
for stream in self._streams.values():
self._write_stream_limits(builder=builder, space=space, stream=stream)
# PING (user-request)
if self._ping_pending:
self._logger.info("Sending PING in packet %d", builder.packet_number)
self._write_ping_frame(builder, self._ping_pending)
self._ping_pending.clear()
# PING (probe)
if self._probe_pending:
self._logger.info(
"Sending PING (probe) in packet %d", builder.packet_number
)
self._write_ping_frame(builder)
self._probe_pending = False
# CRYPTO
if crypto_stream is not None and not crypto_stream.send_buffer_is_empty:
self._write_crypto_frame(
builder=builder, space=space, stream=crypto_stream
)
for stream in self._streams.values():
# STREAM
if not stream.is_blocked and not stream.send_buffer_is_empty:
self._remote_max_data_used += self._write_stream_frame(
builder=builder,
space=space,
stream=stream,
max_offset=min(
stream._send_highest
+ self._remote_max_data
- self._remote_max_data_used,
stream.max_stream_data_remote,
),
===========unchanged ref 0===========
at: aioquic._buffer.Buffer
push_bytes(value: bytes) -> None
at: aioquic.quic.connection
QuicNetworkPath(addr: NetworkAddress, bytes_received: int=0, bytes_sent: int=0, is_validated: bool=False, local_challenge: Optional[bytes]=None, remote_challenge: Optional[bytes]=None)
at: aioquic.quic.connection.QuicConnection
_write_ack_frame(self, builder: QuicPacketBuilder, space: QuicPacketSpace)
_write_ack_frame(builder: QuicPacketBuilder, space: QuicPacketSpace)
_write_connection_limits(self, builder: QuicPacketBuilder, space: QuicPacketSpace) -> None
_write_connection_limits(builder: QuicPacketBuilder, space: QuicPacketSpace) -> None
_write_crypto_frame(builder: QuicPacketBuilder, space: QuicPacketSpace, stream: QuicStream) -> None
_write_crypto_frame(self, builder: QuicPacketBuilder, space: QuicPacketSpace, stream: QuicStream) -> None
_write_new_connection_id_frame(builder: QuicPacketBuilder, connection_id: QuicConnectionId) -> None
_write_new_connection_id_frame(self, builder: QuicPacketBuilder, connection_id: QuicConnectionId) -> None
_write_ping_frame(builder: QuicPacketBuilder, uids: List[int]=[])
_write_ping_frame(self, builder: QuicPacketBuilder, uids: List[int]=[])
_write_retire_connection_id_frame(builder: QuicPacketBuilder, sequence_number: int) -> None
_write_retire_connection_id_frame(self, builder: QuicPacketBuilder, sequence_number: int) -> None
===========unchanged ref 1===========
_write_stream_frame(builder: QuicPacketBuilder, space: QuicPacketSpace, stream: QuicStream, max_offset: int) -> int
_write_stream_frame(self, builder: QuicPacketBuilder, space: QuicPacketSpace, stream: QuicStream, max_offset: int) -> int
_write_stream_limits(self, builder: QuicPacketBuilder, space: QuicPacketSpace, stream: QuicStream) -> None
_write_stream_limits(builder: QuicPacketBuilder, space: QuicPacketSpace, stream: QuicStream) -> None
_write_streams_blocked_frame(builder: QuicPacketBuilder, frame_type: QuicFrameType, limit: int) -> None
_write_streams_blocked_frame(self, builder: QuicPacketBuilder, frame_type: QuicFrameType, limit: int) -> None
at: aioquic.quic.connection.QuicConnection.__init__
self._quic_logger = configuration.quic_logger
self._cryptos: Dict[tls.Epoch, CryptoPair] = {}
self._crypto_streams: Dict[tls.Epoch, QuicStream] = {}
self._handshake_complete = False
self._host_cids = [
QuicConnectionId(
cid=os.urandom(8),
sequence_number=0,
stateless_reset_token=os.urandom(16),
was_sent=True,
)
]
self._logger = QuicConnectionAdapter(
logger, {"host_cid": dump_cid(self.host_cid)}
)
self._remote_max_data = 0
self._remote_max_data_used = 0
self._remote_max_streams_bidi = 0
self._remote_max_streams_uni = 0
self._spaces: Dict[tls.Epoch, QuicPacketSpace] = {}
self._streams: Dict[int, QuicStream] = {}
self._streams_blocked_bidi: List[QuicStream] = []
|
aioquic.quic.connection/QuicConnection._write_ack_frame
|
Modified
|
aiortc~aioquic
|
f89f264ca7ff9bf69a5ec2c3550bb0ffa67db2da
|
[qlog] switch to draft-01
|
<10>:<add> builder.quic_logger_frames.append(
<del> builder._packet.quic_logger_frames.append(
|
# module: aioquic.quic.connection
class QuicConnection:
def _write_ack_frame(self, builder: QuicPacketBuilder, space: QuicPacketSpace):
<0> builder.start_frame(
<1> QuicFrameType.ACK,
<2> self._on_ack_delivery,
<3> (space, space.largest_received_packet),
<4> )
<5> push_ack_frame(builder.buffer, space.ack_queue, 0)
<6> space.ack_at = None
<7>
<8> # log frame
<9> if self._quic_logger is not None:
<10> builder._packet.quic_logger_frames.append(
<11> self._quic_logger.encode_ack_frame(ranges=space.ack_queue, delay=0.0)
<12> )
<13>
|
===========unchanged ref 0===========
at: aioquic.quic.connection.QuicConnection
_on_ack_delivery(delivery: QuicDeliveryState, space: QuicPacketSpace, highest_acked: int) -> None
at: aioquic.quic.connection.QuicConnection.__init__
self._quic_logger = configuration.quic_logger
at: aioquic.quic.packet
QuicFrameType(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
QuicFrameType(x: Union[str, bytes, bytearray], base: int)
push_ack_frame(buf: Buffer, rangeset: RangeSet, delay: int) -> None
at: aioquic.quic.packet_builder
QuicPacketBuilder(*, host_cid: bytes, peer_cid: bytes, version: int, pad_first_datagram: bool=False, packet_number: int=0, peer_token: bytes=b"", quic_logger: Optional[QuicLogger]=None, spin_bit: bool=False)
at: aioquic.quic.packet_builder.QuicPacketBuilder
start_frame(frame_type: int, handler: Optional[QuicDeliveryHandler]=None, args: Sequence[Any]=[]) -> None
at: aioquic.quic.packet_builder.QuicPacketBuilder.__init__
self._packet: Optional[QuicSentPacket] = None
self.buffer = Buffer(PACKET_MAX_SIZE)
at: aioquic.quic.packet_builder.QuicPacketBuilder.end_packet
self._packet = None
at: aioquic.quic.packet_builder.QuicPacketBuilder.start_packet
self._packet = QuicSentPacket(
epoch=epoch,
in_flight=False,
is_ack_eliciting=False,
is_crypto_packet=False,
packet_number=self._packet_number,
packet_type=packet_type,
)
===========unchanged ref 1===========
at: aioquic.quic.packet_builder.QuicSentPacket
quic_logger_frames: List[Dict] = field(default_factory=list)
at: aioquic.quic.recovery
QuicPacketSpace()
at: aioquic.quic.recovery.QuicPacketSpace.__init__
self.ack_at: Optional[float] = None
self.ack_queue = RangeSet()
self.largest_received_packet = 0
===========changed ref 0===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_ping_frame(self) -> Dict:
+ return {"frame_type": "ping"}
- return {"frame_type": "PING"}
===========changed ref 1===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_padding_frame(self) -> Dict:
+ return {"frame_type": "padding"}
- return {"frame_type": "PADDING"}
===========changed ref 2===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_data_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_data", "maximum": str(maximum)}
- return {"frame_type": "MAX_DATA", "maximum": str(maximum)}
===========changed ref 3===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_streams_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_streams", "maximum": str(maximum)}
- return {"frame_type": "MAX_STREAMS", "maximum": str(maximum)}
===========changed ref 4===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_data_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "data_blocked", "limit": str(limit)}
- return {"frame_type": "DATA_BLOCKED", "limit": str(limit)}
===========changed ref 5===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_streams_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "streams_blocked", "limit": str(limit)}
- return {"frame_type": "STREAMS_BLOCKED", "limit": str(limit)}
===========changed ref 6===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_path_response_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "path_response"}
- return {"data": hexdump(data), "frame_type": "PATH_RESPONSE"}
===========changed ref 7===========
# module: aioquic.quic.logger
class QuicLogger:
def start_trace(self, is_client: bool) -> None:
+ self._vantage_point["type"] = "client" if is_client else "server"
- self._vantage_point["type"] = "CLIENT" if is_client else "SERVER"
===========changed ref 8===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_path_challenge_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "path_challenge"}
- return {"data": hexdump(data), "frame_type": "PATH_CHALLENGE"}
===========changed ref 9===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_retire_connection_id_frame(self, sequence_number: int) -> Dict:
return {
+ "frame_type": "retire_connection_id",
- "frame_type": "RETIRE_CONNECTION_ID",
"sequence_number": str(sequence_number),
}
===========changed ref 10===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_new_token_frame(self, token: bytes) -> Dict:
return {
+ "frame_type": "new_token",
- "frame_type": "NEW_TOKEN",
"length": str(len(token)),
"token": hexdump(token),
}
===========changed ref 11===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_stop_sending_frame(self, error_code: int, stream_id: int) -> Dict:
return {
+ "frame_type": "stop_sending",
- "frame_type": "STOP_SENDING",
"id": str(stream_id),
"error_code": error_code,
}
===========changed ref 12===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_reset_stream_frame(
self, error_code: int, final_size: int, stream_id: int
) -> Dict:
return {
"error_code": error_code,
"final_size": str(final_size),
+ "frame_type": "reset_stream",
- "frame_type": "RESET_STREAM",
}
===========changed ref 13===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_stream_data_frame(self, maximum: int, stream_id: int) -> Dict:
return {
+ "frame_type": "max_stream_data",
- "frame_type": "MAX_STREAM_DATA",
"id": str(stream_id),
"maximum": str(maximum),
}
===========changed ref 14===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_stream_data_blocked_frame(self, limit: int, stream_id: int) -> Dict:
return {
+ "frame_type": "stream_data_blocked",
- "frame_type": "STREAM_DATA_BLOCKED",
"limit": str(limit),
"stream_id": str(stream_id),
}
|
aioquic.quic.connection/QuicConnection._write_close_frame
|
Modified
|
aiortc~aioquic
|
f89f264ca7ff9bf69a5ec2c3550bb0ffa67db2da
|
[qlog] switch to draft-01
|
<18>:<add> builder.quic_logger_frames.append(
<del> builder._packet.quic_logger_frames.append(
|
# module: aioquic.quic.connection
class QuicConnection:
def _write_close_frame(
self,
builder: QuicPacketBuilder,
error_code: int,
frame_type: Optional[int],
reason_phrase: str,
) -> None:
<0> buf = builder.buffer
<1>
<2> reason_bytes = reason_phrase.encode("utf8")
<3>
<4> if frame_type is None:
<5> builder.start_frame(QuicFrameType.APPLICATION_CLOSE)
<6> buf.push_uint_var(error_code)
<7> buf.push_uint_var(len(reason_bytes))
<8> buf.push_bytes(reason_bytes)
<9> else:
<10> builder.start_frame(QuicFrameType.TRANSPORT_CLOSE)
<11> buf.push_uint_var(error_code)
<12> buf.push_uint_var(frame_type)
<13> buf.push_uint_var(len(reason_bytes))
<14> buf.push_bytes(reason_bytes)
<15>
<16> # log frame
<17> if self._quic_logger is not None:
<18> builder._packet.quic_logger_frames.append(
<19> self._quic_logger.encode_connection_close_frame(
<20> error_code=error_code,
<21> frame_type=frame_type,
<22> reason_phrase=reason_phrase,
<23> )
<24> )
<25>
|
===========unchanged ref 0===========
at: aioquic._buffer.Buffer
push_bytes(value: bytes) -> None
push_uint_var(value: int) -> None
at: aioquic.quic.connection.QuicConnection.__init__
self._quic_logger = configuration.quic_logger
at: aioquic.quic.packet
QuicFrameType(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
QuicFrameType(x: Union[str, bytes, bytearray], base: int)
at: aioquic.quic.packet_builder
QuicPacketBuilder(*, host_cid: bytes, peer_cid: bytes, version: int, pad_first_datagram: bool=False, packet_number: int=0, peer_token: bytes=b"", quic_logger: Optional[QuicLogger]=None, spin_bit: bool=False)
at: aioquic.quic.packet_builder.QuicPacketBuilder
start_frame(frame_type: int, handler: Optional[QuicDeliveryHandler]=None, args: Sequence[Any]=[]) -> None
at: aioquic.quic.packet_builder.QuicPacketBuilder.__init__
self._packet: Optional[QuicSentPacket] = None
self.buffer = Buffer(PACKET_MAX_SIZE)
at: aioquic.quic.packet_builder.QuicPacketBuilder.end_packet
self._packet = None
at: aioquic.quic.packet_builder.QuicPacketBuilder.start_packet
self._packet = QuicSentPacket(
epoch=epoch,
in_flight=False,
is_ack_eliciting=False,
is_crypto_packet=False,
packet_number=self._packet_number,
packet_type=packet_type,
)
at: aioquic.quic.packet_builder.QuicSentPacket
quic_logger_frames: List[Dict] = field(default_factory=list)
===========changed ref 0===========
# module: aioquic.quic.connection
class QuicConnection:
def _write_ack_frame(self, builder: QuicPacketBuilder, space: QuicPacketSpace):
builder.start_frame(
QuicFrameType.ACK,
self._on_ack_delivery,
(space, space.largest_received_packet),
)
push_ack_frame(builder.buffer, space.ack_queue, 0)
space.ack_at = None
# log frame
if self._quic_logger is not None:
+ builder.quic_logger_frames.append(
- builder._packet.quic_logger_frames.append(
self._quic_logger.encode_ack_frame(ranges=space.ack_queue, delay=0.0)
)
===========changed ref 1===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_ping_frame(self) -> Dict:
+ return {"frame_type": "ping"}
- return {"frame_type": "PING"}
===========changed ref 2===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_padding_frame(self) -> Dict:
+ return {"frame_type": "padding"}
- return {"frame_type": "PADDING"}
===========changed ref 3===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_data_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_data", "maximum": str(maximum)}
- return {"frame_type": "MAX_DATA", "maximum": str(maximum)}
===========changed ref 4===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_streams_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_streams", "maximum": str(maximum)}
- return {"frame_type": "MAX_STREAMS", "maximum": str(maximum)}
===========changed ref 5===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_data_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "data_blocked", "limit": str(limit)}
- return {"frame_type": "DATA_BLOCKED", "limit": str(limit)}
===========changed ref 6===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_streams_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "streams_blocked", "limit": str(limit)}
- return {"frame_type": "STREAMS_BLOCKED", "limit": str(limit)}
===========changed ref 7===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_path_response_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "path_response"}
- return {"data": hexdump(data), "frame_type": "PATH_RESPONSE"}
===========changed ref 8===========
# module: aioquic.quic.logger
class QuicLogger:
def start_trace(self, is_client: bool) -> None:
+ self._vantage_point["type"] = "client" if is_client else "server"
- self._vantage_point["type"] = "CLIENT" if is_client else "SERVER"
===========changed ref 9===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_path_challenge_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "path_challenge"}
- return {"data": hexdump(data), "frame_type": "PATH_CHALLENGE"}
===========changed ref 10===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_retire_connection_id_frame(self, sequence_number: int) -> Dict:
return {
+ "frame_type": "retire_connection_id",
- "frame_type": "RETIRE_CONNECTION_ID",
"sequence_number": str(sequence_number),
}
===========changed ref 11===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_new_token_frame(self, token: bytes) -> Dict:
return {
+ "frame_type": "new_token",
- "frame_type": "NEW_TOKEN",
"length": str(len(token)),
"token": hexdump(token),
}
===========changed ref 12===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_stop_sending_frame(self, error_code: int, stream_id: int) -> Dict:
return {
+ "frame_type": "stop_sending",
- "frame_type": "STOP_SENDING",
"id": str(stream_id),
"error_code": error_code,
}
===========changed ref 13===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_reset_stream_frame(
self, error_code: int, final_size: int, stream_id: int
) -> Dict:
return {
"error_code": error_code,
"final_size": str(final_size),
+ "frame_type": "reset_stream",
- "frame_type": "RESET_STREAM",
}
===========changed ref 14===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_stream_data_frame(self, maximum: int, stream_id: int) -> Dict:
return {
+ "frame_type": "max_stream_data",
- "frame_type": "MAX_STREAM_DATA",
"id": str(stream_id),
"maximum": str(maximum),
}
|
aioquic.quic.connection/QuicConnection._write_connection_limits
|
Modified
|
aiortc~aioquic
|
f89f264ca7ff9bf69a5ec2c3550bb0ffa67db2da
|
[qlog] switch to draft-01
|
<11>:<add> builder.quic_logger_frames.append(
<del> builder._packet.quic_logger_frames.append(
|
# module: aioquic.quic.connection
class QuicConnection:
def _write_connection_limits(
self, builder: QuicPacketBuilder, space: QuicPacketSpace
) -> None:
<0> # raise MAX_DATA if needed
<1> if self._local_max_data_used > self._local_max_data * 0.75:
<2> self._local_max_data *= 2
<3> self._logger.debug("Local max_data raised to %d", self._local_max_data)
<4> if self._local_max_data_sent != self._local_max_data:
<5> builder.start_frame(QuicFrameType.MAX_DATA, self._on_max_data_delivery)
<6> builder.buffer.push_uint_var(self._local_max_data)
<7> self._local_max_data_sent = self._local_max_data
<8>
<9> # log frame
<10> if self._quic_logger is not None:
<11> builder._packet.quic_logger_frames.append(
<12> self._quic_logger.encode_max_data_frame(self._local_max_data)
<13> )
<14>
|
===========unchanged ref 0===========
at: aioquic._buffer.Buffer
push_uint_var(value: int) -> None
at: aioquic.quic.connection.QuicConnection
_on_max_data_delivery(delivery: QuicDeliveryState) -> None
at: aioquic.quic.connection.QuicConnection.__init__
self._quic_logger = configuration.quic_logger
self._local_max_data = MAX_DATA_WINDOW
self._local_max_data_sent = MAX_DATA_WINDOW
self._local_max_data_used = 0
self._logger = QuicConnectionAdapter(
logger, {"host_cid": dump_cid(self.host_cid)}
)
at: aioquic.quic.connection.QuicConnection._handle_stream_frame
self._local_max_data_used += newly_received
at: aioquic.quic.connection.QuicConnection._on_max_data_delivery
self._local_max_data_sent = 0
at: aioquic.quic.packet
QuicFrameType(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
QuicFrameType(x: Union[str, bytes, bytearray], base: int)
at: aioquic.quic.packet_builder
QuicPacketBuilder(*, host_cid: bytes, peer_cid: bytes, version: int, pad_first_datagram: bool=False, packet_number: int=0, peer_token: bytes=b"", quic_logger: Optional[QuicLogger]=None, spin_bit: bool=False)
at: aioquic.quic.packet_builder.QuicPacketBuilder
start_frame(frame_type: int, handler: Optional[QuicDeliveryHandler]=None, args: Sequence[Any]=[]) -> None
at: aioquic.quic.packet_builder.QuicPacketBuilder.__init__
self._packet: Optional[QuicSentPacket] = None
self.buffer = Buffer(PACKET_MAX_SIZE)
===========unchanged ref 1===========
at: aioquic.quic.packet_builder.QuicPacketBuilder.end_packet
self._packet = None
at: aioquic.quic.packet_builder.QuicPacketBuilder.start_packet
self._packet = QuicSentPacket(
epoch=epoch,
in_flight=False,
is_ack_eliciting=False,
is_crypto_packet=False,
packet_number=self._packet_number,
packet_type=packet_type,
)
at: aioquic.quic.packet_builder.QuicSentPacket
quic_logger_frames: List[Dict] = field(default_factory=list)
at: aioquic.quic.recovery
QuicPacketSpace()
===========changed ref 0===========
# module: aioquic.quic.connection
class QuicConnection:
def _write_ack_frame(self, builder: QuicPacketBuilder, space: QuicPacketSpace):
builder.start_frame(
QuicFrameType.ACK,
self._on_ack_delivery,
(space, space.largest_received_packet),
)
push_ack_frame(builder.buffer, space.ack_queue, 0)
space.ack_at = None
# log frame
if self._quic_logger is not None:
+ builder.quic_logger_frames.append(
- builder._packet.quic_logger_frames.append(
self._quic_logger.encode_ack_frame(ranges=space.ack_queue, delay=0.0)
)
===========changed ref 1===========
# module: aioquic.quic.connection
class QuicConnection:
def _write_close_frame(
self,
builder: QuicPacketBuilder,
error_code: int,
frame_type: Optional[int],
reason_phrase: str,
) -> None:
buf = builder.buffer
reason_bytes = reason_phrase.encode("utf8")
if frame_type is None:
builder.start_frame(QuicFrameType.APPLICATION_CLOSE)
buf.push_uint_var(error_code)
buf.push_uint_var(len(reason_bytes))
buf.push_bytes(reason_bytes)
else:
builder.start_frame(QuicFrameType.TRANSPORT_CLOSE)
buf.push_uint_var(error_code)
buf.push_uint_var(frame_type)
buf.push_uint_var(len(reason_bytes))
buf.push_bytes(reason_bytes)
# log frame
if self._quic_logger is not None:
+ builder.quic_logger_frames.append(
- builder._packet.quic_logger_frames.append(
self._quic_logger.encode_connection_close_frame(
error_code=error_code,
frame_type=frame_type,
reason_phrase=reason_phrase,
)
)
===========changed ref 2===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_ping_frame(self) -> Dict:
+ return {"frame_type": "ping"}
- return {"frame_type": "PING"}
===========changed ref 3===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_padding_frame(self) -> Dict:
+ return {"frame_type": "padding"}
- return {"frame_type": "PADDING"}
===========changed ref 4===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_data_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_data", "maximum": str(maximum)}
- return {"frame_type": "MAX_DATA", "maximum": str(maximum)}
===========changed ref 5===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_streams_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_streams", "maximum": str(maximum)}
- return {"frame_type": "MAX_STREAMS", "maximum": str(maximum)}
===========changed ref 6===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_data_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "data_blocked", "limit": str(limit)}
- return {"frame_type": "DATA_BLOCKED", "limit": str(limit)}
===========changed ref 7===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_streams_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "streams_blocked", "limit": str(limit)}
- return {"frame_type": "STREAMS_BLOCKED", "limit": str(limit)}
===========changed ref 8===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_path_response_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "path_response"}
- return {"data": hexdump(data), "frame_type": "PATH_RESPONSE"}
===========changed ref 9===========
# module: aioquic.quic.logger
class QuicLogger:
def start_trace(self, is_client: bool) -> None:
+ self._vantage_point["type"] = "client" if is_client else "server"
- self._vantage_point["type"] = "CLIENT" if is_client else "SERVER"
===========changed ref 10===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_path_challenge_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "path_challenge"}
- return {"data": hexdump(data), "frame_type": "PATH_CHALLENGE"}
|
aioquic.quic.connection/QuicConnection._write_crypto_frame
|
Modified
|
aiortc~aioquic
|
f89f264ca7ff9bf69a5ec2c3550bb0ffa67db2da
|
[qlog] switch to draft-01
|
<16>:<add> builder.quic_logger_frames.append(
<del> builder._packet.quic_logger_frames.append(
|
# module: aioquic.quic.connection
class QuicConnection:
def _write_crypto_frame(
self, builder: QuicPacketBuilder, space: QuicPacketSpace, stream: QuicStream
) -> None:
<0> buf = builder.buffer
<1>
<2> frame_overhead = 3 + size_uint_var(stream.next_send_offset)
<3> frame = stream.get_frame(builder.remaining_space - frame_overhead)
<4> if frame is not None:
<5> builder.start_frame(
<6> QuicFrameType.CRYPTO,
<7> stream.on_data_delivery,
<8> (frame.offset, frame.offset + len(frame.data)),
<9> )
<10> buf.push_uint_var(frame.offset)
<11> buf.push_uint16(len(frame.data) | 0x4000)
<12> buf.push_bytes(frame.data)
<13>
<14> # log frame
<15> if self._quic_logger is not None:
<16> builder._packet.quic_logger_frames.append(
<17> self._quic_logger.encode_crypto_frame(frame)
<18> )
<19>
|
===========unchanged ref 0===========
at: aioquic._buffer.Buffer
push_bytes(value: bytes) -> None
push_uint16(value: int) -> None
push_uint_var(value: int) -> None
at: aioquic.buffer
size_uint_var(value: int) -> int
at: aioquic.quic.connection.QuicConnection.__init__
self._quic_logger = configuration.quic_logger
at: aioquic.quic.packet
QuicFrameType(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
QuicFrameType(x: Union[str, bytes, bytearray], base: int)
at: aioquic.quic.packet.QuicStreamFrame
data: bytes = b""
fin: bool = False
offset: int = 0
at: aioquic.quic.packet_builder
QuicPacketBuilder(*, host_cid: bytes, peer_cid: bytes, version: int, pad_first_datagram: bool=False, packet_number: int=0, peer_token: bytes=b"", quic_logger: Optional[QuicLogger]=None, spin_bit: bool=False)
at: aioquic.quic.packet_builder.QuicPacketBuilder
start_frame(frame_type: int, handler: Optional[QuicDeliveryHandler]=None, args: Sequence[Any]=[]) -> None
at: aioquic.quic.packet_builder.QuicPacketBuilder.__init__
self._packet: Optional[QuicSentPacket] = None
self.buffer = Buffer(PACKET_MAX_SIZE)
at: aioquic.quic.packet_builder.QuicPacketBuilder.end_packet
self._packet = None
===========unchanged ref 1===========
at: aioquic.quic.packet_builder.QuicPacketBuilder.start_packet
self._packet = QuicSentPacket(
epoch=epoch,
in_flight=False,
is_ack_eliciting=False,
is_crypto_packet=False,
packet_number=self._packet_number,
packet_type=packet_type,
)
at: aioquic.quic.packet_builder.QuicSentPacket
quic_logger_frames: List[Dict] = field(default_factory=list)
at: aioquic.quic.recovery
QuicPacketSpace()
at: aioquic.quic.stream
QuicStream(stream_id: Optional[int]=None, connection: Optional[Any]=None, max_stream_data_local: int=0, max_stream_data_remote: int=0)
at: aioquic.quic.stream.QuicStream
get_frame(max_size: int, max_offset: Optional[int]=None) -> Optional[QuicStreamFrame]
on_data_delivery(delivery: QuicDeliveryState, start: int, stop: int) -> None
===========changed ref 0===========
# module: aioquic.quic.connection
class QuicConnection:
def _write_ack_frame(self, builder: QuicPacketBuilder, space: QuicPacketSpace):
builder.start_frame(
QuicFrameType.ACK,
self._on_ack_delivery,
(space, space.largest_received_packet),
)
push_ack_frame(builder.buffer, space.ack_queue, 0)
space.ack_at = None
# log frame
if self._quic_logger is not None:
+ builder.quic_logger_frames.append(
- builder._packet.quic_logger_frames.append(
self._quic_logger.encode_ack_frame(ranges=space.ack_queue, delay=0.0)
)
===========changed ref 1===========
# module: aioquic.quic.connection
class QuicConnection:
def _write_connection_limits(
self, builder: QuicPacketBuilder, space: QuicPacketSpace
) -> None:
# raise MAX_DATA if needed
if self._local_max_data_used > self._local_max_data * 0.75:
self._local_max_data *= 2
self._logger.debug("Local max_data raised to %d", self._local_max_data)
if self._local_max_data_sent != self._local_max_data:
builder.start_frame(QuicFrameType.MAX_DATA, self._on_max_data_delivery)
builder.buffer.push_uint_var(self._local_max_data)
self._local_max_data_sent = self._local_max_data
# log frame
if self._quic_logger is not None:
+ builder.quic_logger_frames.append(
- builder._packet.quic_logger_frames.append(
self._quic_logger.encode_max_data_frame(self._local_max_data)
)
===========changed ref 2===========
# module: aioquic.quic.connection
class QuicConnection:
def _write_close_frame(
self,
builder: QuicPacketBuilder,
error_code: int,
frame_type: Optional[int],
reason_phrase: str,
) -> None:
buf = builder.buffer
reason_bytes = reason_phrase.encode("utf8")
if frame_type is None:
builder.start_frame(QuicFrameType.APPLICATION_CLOSE)
buf.push_uint_var(error_code)
buf.push_uint_var(len(reason_bytes))
buf.push_bytes(reason_bytes)
else:
builder.start_frame(QuicFrameType.TRANSPORT_CLOSE)
buf.push_uint_var(error_code)
buf.push_uint_var(frame_type)
buf.push_uint_var(len(reason_bytes))
buf.push_bytes(reason_bytes)
# log frame
if self._quic_logger is not None:
+ builder.quic_logger_frames.append(
- builder._packet.quic_logger_frames.append(
self._quic_logger.encode_connection_close_frame(
error_code=error_code,
frame_type=frame_type,
reason_phrase=reason_phrase,
)
)
===========changed ref 3===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_ping_frame(self) -> Dict:
+ return {"frame_type": "ping"}
- return {"frame_type": "PING"}
===========changed ref 4===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_padding_frame(self) -> Dict:
+ return {"frame_type": "padding"}
- return {"frame_type": "PADDING"}
===========changed ref 5===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_data_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_data", "maximum": str(maximum)}
- return {"frame_type": "MAX_DATA", "maximum": str(maximum)}
===========changed ref 6===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_streams_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_streams", "maximum": str(maximum)}
- return {"frame_type": "MAX_STREAMS", "maximum": str(maximum)}
===========changed ref 7===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_data_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "data_blocked", "limit": str(limit)}
- return {"frame_type": "DATA_BLOCKED", "limit": str(limit)}
===========changed ref 8===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_streams_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "streams_blocked", "limit": str(limit)}
- return {"frame_type": "STREAMS_BLOCKED", "limit": str(limit)}
|
aioquic.quic.connection/QuicConnection._write_new_connection_id_frame
|
Modified
|
aiortc~aioquic
|
f89f264ca7ff9bf69a5ec2c3550bb0ffa67db2da
|
[qlog] switch to draft-01
|
<17>:<add> builder.quic_logger_frames.append(
<del> builder._packet.quic_logger_frames.append(
|
# module: aioquic.quic.connection
class QuicConnection:
def _write_new_connection_id_frame(
self, builder: QuicPacketBuilder, connection_id: QuicConnectionId
) -> None:
<0> builder.start_frame(
<1> QuicFrameType.NEW_CONNECTION_ID,
<2> self._on_new_connection_id_delivery,
<3> (connection_id,),
<4> )
<5> frame = QuicNewConnectionIdFrame(
<6> sequence_number=connection_id.sequence_number,
<7> retire_prior_to=0, # FIXME
<8> connection_id=connection_id.cid,
<9> stateless_reset_token=connection_id.stateless_reset_token,
<10> )
<11> push_new_connection_id_frame(builder.buffer, frame)
<12> connection_id.was_sent = True
<13> self._events.append(events.ConnectionIdIssued(connection_id=connection_id.cid))
<14>
<15> # log frame
<16> if self._quic_logger is not None:
<17> builder._packet.quic_logger_frames.append(
<18> self._quic_logger.encode_new_connection_id_frame(frame)
<19> )
<20>
|
===========unchanged ref 0===========
at: aioquic.quic.connection
QuicConnectionId(cid: bytes, sequence_number: int, stateless_reset_token: bytes=b"", was_sent: bool=False)
at: aioquic.quic.connection.QuicConnection
_on_new_connection_id_delivery(delivery: QuicDeliveryState, connection_id: QuicConnectionId) -> None
at: aioquic.quic.connection.QuicConnection.__init__
self._quic_logger = configuration.quic_logger
self._events: Deque[events.QuicEvent] = deque()
at: aioquic.quic.connection.QuicConnectionId
cid: bytes
sequence_number: int
stateless_reset_token: bytes = b""
was_sent: bool = False
at: aioquic.quic.events
ConnectionIdIssued(connection_id: bytes)
at: aioquic.quic.events.ConnectionIdIssued
connection_id: bytes
at: aioquic.quic.packet
QuicFrameType(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
QuicFrameType(x: Union[str, bytes, bytearray], base: int)
QuicNewConnectionIdFrame(sequence_number: int, retire_prior_to: int, connection_id: bytes, stateless_reset_token: bytes)
push_new_connection_id_frame(buf: Buffer, frame: QuicNewConnectionIdFrame) -> None
at: aioquic.quic.packet.QuicNewConnectionIdFrame
sequence_number: int
retire_prior_to: int
connection_id: bytes
stateless_reset_token: bytes
===========unchanged ref 1===========
at: aioquic.quic.packet_builder
QuicPacketBuilder(*, host_cid: bytes, peer_cid: bytes, version: int, pad_first_datagram: bool=False, packet_number: int=0, peer_token: bytes=b"", quic_logger: Optional[QuicLogger]=None, spin_bit: bool=False)
at: aioquic.quic.packet_builder.QuicPacketBuilder
start_frame(frame_type: int, handler: Optional[QuicDeliveryHandler]=None, args: Sequence[Any]=[]) -> None
at: aioquic.quic.packet_builder.QuicPacketBuilder.__init__
self._packet: Optional[QuicSentPacket] = None
self.buffer = Buffer(PACKET_MAX_SIZE)
at: aioquic.quic.packet_builder.QuicPacketBuilder.end_packet
self._packet = None
at: aioquic.quic.packet_builder.QuicPacketBuilder.start_packet
self._packet = QuicSentPacket(
epoch=epoch,
in_flight=False,
is_ack_eliciting=False,
is_crypto_packet=False,
packet_number=self._packet_number,
packet_type=packet_type,
)
at: aioquic.quic.packet_builder.QuicSentPacket
quic_logger_frames: List[Dict] = field(default_factory=list)
===========changed ref 0===========
# module: aioquic.quic.connection
class QuicConnection:
def _write_crypto_frame(
self, builder: QuicPacketBuilder, space: QuicPacketSpace, stream: QuicStream
) -> None:
buf = builder.buffer
frame_overhead = 3 + size_uint_var(stream.next_send_offset)
frame = stream.get_frame(builder.remaining_space - frame_overhead)
if frame is not None:
builder.start_frame(
QuicFrameType.CRYPTO,
stream.on_data_delivery,
(frame.offset, frame.offset + len(frame.data)),
)
buf.push_uint_var(frame.offset)
buf.push_uint16(len(frame.data) | 0x4000)
buf.push_bytes(frame.data)
# log frame
if self._quic_logger is not None:
+ builder.quic_logger_frames.append(
- builder._packet.quic_logger_frames.append(
self._quic_logger.encode_crypto_frame(frame)
)
===========changed ref 1===========
# module: aioquic.quic.connection
class QuicConnection:
def _write_ack_frame(self, builder: QuicPacketBuilder, space: QuicPacketSpace):
builder.start_frame(
QuicFrameType.ACK,
self._on_ack_delivery,
(space, space.largest_received_packet),
)
push_ack_frame(builder.buffer, space.ack_queue, 0)
space.ack_at = None
# log frame
if self._quic_logger is not None:
+ builder.quic_logger_frames.append(
- builder._packet.quic_logger_frames.append(
self._quic_logger.encode_ack_frame(ranges=space.ack_queue, delay=0.0)
)
===========changed ref 2===========
# module: aioquic.quic.connection
class QuicConnection:
def _write_connection_limits(
self, builder: QuicPacketBuilder, space: QuicPacketSpace
) -> None:
# raise MAX_DATA if needed
if self._local_max_data_used > self._local_max_data * 0.75:
self._local_max_data *= 2
self._logger.debug("Local max_data raised to %d", self._local_max_data)
if self._local_max_data_sent != self._local_max_data:
builder.start_frame(QuicFrameType.MAX_DATA, self._on_max_data_delivery)
builder.buffer.push_uint_var(self._local_max_data)
self._local_max_data_sent = self._local_max_data
# log frame
if self._quic_logger is not None:
+ builder.quic_logger_frames.append(
- builder._packet.quic_logger_frames.append(
self._quic_logger.encode_max_data_frame(self._local_max_data)
)
===========changed ref 3===========
# module: aioquic.quic.connection
class QuicConnection:
def _write_close_frame(
self,
builder: QuicPacketBuilder,
error_code: int,
frame_type: Optional[int],
reason_phrase: str,
) -> None:
buf = builder.buffer
reason_bytes = reason_phrase.encode("utf8")
if frame_type is None:
builder.start_frame(QuicFrameType.APPLICATION_CLOSE)
buf.push_uint_var(error_code)
buf.push_uint_var(len(reason_bytes))
buf.push_bytes(reason_bytes)
else:
builder.start_frame(QuicFrameType.TRANSPORT_CLOSE)
buf.push_uint_var(error_code)
buf.push_uint_var(frame_type)
buf.push_uint_var(len(reason_bytes))
buf.push_bytes(reason_bytes)
# log frame
if self._quic_logger is not None:
+ builder.quic_logger_frames.append(
- builder._packet.quic_logger_frames.append(
self._quic_logger.encode_connection_close_frame(
error_code=error_code,
frame_type=frame_type,
reason_phrase=reason_phrase,
)
)
===========changed ref 4===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_ping_frame(self) -> Dict:
+ return {"frame_type": "ping"}
- return {"frame_type": "PING"}
|
aioquic.quic.connection/QuicConnection._write_ping_frame
|
Modified
|
aiortc~aioquic
|
f89f264ca7ff9bf69a5ec2c3550bb0ffa67db2da
|
[qlog] switch to draft-01
|
<4>:<del> builder._packet.quic_logger_frames.append(
<5>:<del> self._quic_logger.encode_ping_frame()
<6>:<del> )
<7>:<add> builder.quic_logger_frames.append(self._quic_logger.encode_ping_frame())
|
# module: aioquic.quic.connection
class QuicConnection:
def _write_ping_frame(self, builder: QuicPacketBuilder, uids: List[int] = []):
<0> builder.start_frame(QuicFrameType.PING, self._on_ping_delivery, (tuple(uids),))
<1>
<2> # log frame
<3> if self._quic_logger is not None:
<4> builder._packet.quic_logger_frames.append(
<5> self._quic_logger.encode_ping_frame()
<6> )
<7>
|
===========unchanged ref 0===========
at: aioquic.quic.connection.QuicConnection
_on_ping_delivery(delivery: QuicDeliveryState, uids: Sequence[int]) -> None
at: aioquic.quic.connection.QuicConnection.__init__
self._quic_logger = configuration.quic_logger
at: aioquic.quic.packet
QuicFrameType(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
QuicFrameType(x: Union[str, bytes, bytearray], base: int)
at: aioquic.quic.packet_builder
QuicPacketBuilder(*, host_cid: bytes, peer_cid: bytes, version: int, pad_first_datagram: bool=False, packet_number: int=0, peer_token: bytes=b"", quic_logger: Optional[QuicLogger]=None, spin_bit: bool=False)
at: aioquic.quic.packet_builder.QuicPacketBuilder
start_frame(frame_type: int, handler: Optional[QuicDeliveryHandler]=None, args: Sequence[Any]=[]) -> None
at: aioquic.quic.packet_builder.QuicPacketBuilder.__init__
self._packet: Optional[QuicSentPacket] = None
at: aioquic.quic.packet_builder.QuicPacketBuilder.end_packet
self._packet = None
at: aioquic.quic.packet_builder.QuicPacketBuilder.start_packet
self._packet = QuicSentPacket(
epoch=epoch,
in_flight=False,
is_ack_eliciting=False,
is_crypto_packet=False,
packet_number=self._packet_number,
packet_type=packet_type,
)
at: aioquic.quic.packet_builder.QuicSentPacket
quic_logger_frames: List[Dict] = field(default_factory=list)
at: typing
List = _alias(list, 1, inst=False, name='List')
===========changed ref 0===========
# module: aioquic.quic.connection
class QuicConnection:
def _write_new_connection_id_frame(
self, builder: QuicPacketBuilder, connection_id: QuicConnectionId
) -> None:
builder.start_frame(
QuicFrameType.NEW_CONNECTION_ID,
self._on_new_connection_id_delivery,
(connection_id,),
)
frame = QuicNewConnectionIdFrame(
sequence_number=connection_id.sequence_number,
retire_prior_to=0, # FIXME
connection_id=connection_id.cid,
stateless_reset_token=connection_id.stateless_reset_token,
)
push_new_connection_id_frame(builder.buffer, frame)
connection_id.was_sent = True
self._events.append(events.ConnectionIdIssued(connection_id=connection_id.cid))
# log frame
if self._quic_logger is not None:
+ builder.quic_logger_frames.append(
- builder._packet.quic_logger_frames.append(
self._quic_logger.encode_new_connection_id_frame(frame)
)
===========changed ref 1===========
# module: aioquic.quic.connection
class QuicConnection:
def _write_crypto_frame(
self, builder: QuicPacketBuilder, space: QuicPacketSpace, stream: QuicStream
) -> None:
buf = builder.buffer
frame_overhead = 3 + size_uint_var(stream.next_send_offset)
frame = stream.get_frame(builder.remaining_space - frame_overhead)
if frame is not None:
builder.start_frame(
QuicFrameType.CRYPTO,
stream.on_data_delivery,
(frame.offset, frame.offset + len(frame.data)),
)
buf.push_uint_var(frame.offset)
buf.push_uint16(len(frame.data) | 0x4000)
buf.push_bytes(frame.data)
# log frame
if self._quic_logger is not None:
+ builder.quic_logger_frames.append(
- builder._packet.quic_logger_frames.append(
self._quic_logger.encode_crypto_frame(frame)
)
===========changed ref 2===========
# module: aioquic.quic.connection
class QuicConnection:
def _write_ack_frame(self, builder: QuicPacketBuilder, space: QuicPacketSpace):
builder.start_frame(
QuicFrameType.ACK,
self._on_ack_delivery,
(space, space.largest_received_packet),
)
push_ack_frame(builder.buffer, space.ack_queue, 0)
space.ack_at = None
# log frame
if self._quic_logger is not None:
+ builder.quic_logger_frames.append(
- builder._packet.quic_logger_frames.append(
self._quic_logger.encode_ack_frame(ranges=space.ack_queue, delay=0.0)
)
===========changed ref 3===========
# module: aioquic.quic.connection
class QuicConnection:
def _write_connection_limits(
self, builder: QuicPacketBuilder, space: QuicPacketSpace
) -> None:
# raise MAX_DATA if needed
if self._local_max_data_used > self._local_max_data * 0.75:
self._local_max_data *= 2
self._logger.debug("Local max_data raised to %d", self._local_max_data)
if self._local_max_data_sent != self._local_max_data:
builder.start_frame(QuicFrameType.MAX_DATA, self._on_max_data_delivery)
builder.buffer.push_uint_var(self._local_max_data)
self._local_max_data_sent = self._local_max_data
# log frame
if self._quic_logger is not None:
+ builder.quic_logger_frames.append(
- builder._packet.quic_logger_frames.append(
self._quic_logger.encode_max_data_frame(self._local_max_data)
)
===========changed ref 4===========
# module: aioquic.quic.connection
class QuicConnection:
def _write_close_frame(
self,
builder: QuicPacketBuilder,
error_code: int,
frame_type: Optional[int],
reason_phrase: str,
) -> None:
buf = builder.buffer
reason_bytes = reason_phrase.encode("utf8")
if frame_type is None:
builder.start_frame(QuicFrameType.APPLICATION_CLOSE)
buf.push_uint_var(error_code)
buf.push_uint_var(len(reason_bytes))
buf.push_bytes(reason_bytes)
else:
builder.start_frame(QuicFrameType.TRANSPORT_CLOSE)
buf.push_uint_var(error_code)
buf.push_uint_var(frame_type)
buf.push_uint_var(len(reason_bytes))
buf.push_bytes(reason_bytes)
# log frame
if self._quic_logger is not None:
+ builder.quic_logger_frames.append(
- builder._packet.quic_logger_frames.append(
self._quic_logger.encode_connection_close_frame(
error_code=error_code,
frame_type=frame_type,
reason_phrase=reason_phrase,
)
)
===========changed ref 5===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_ping_frame(self) -> Dict:
+ return {"frame_type": "ping"}
- return {"frame_type": "PING"}
|
aioquic.quic.connection/QuicConnection._write_retire_connection_id_frame
|
Modified
|
aiortc~aioquic
|
f89f264ca7ff9bf69a5ec2c3550bb0ffa67db2da
|
[qlog] switch to draft-01
|
<9>:<add> builder.quic_logger_frames.append(
<del> builder._packet.quic_logger_frames.append(
|
# module: aioquic.quic.connection
class QuicConnection:
def _write_retire_connection_id_frame(
self, builder: QuicPacketBuilder, sequence_number: int
) -> None:
<0> builder.start_frame(
<1> QuicFrameType.RETIRE_CONNECTION_ID,
<2> self._on_retire_connection_id_delivery,
<3> (sequence_number,),
<4> )
<5> builder.buffer.push_uint_var(sequence_number)
<6>
<7> # log frame
<8> if self._quic_logger is not None:
<9> builder._packet.quic_logger_frames.append(
<10> self._quic_logger.encode_retire_connection_id_frame(sequence_number)
<11> )
<12>
|
===========unchanged ref 0===========
at: aioquic._buffer.Buffer
push_uint_var(value: int) -> None
at: aioquic.quic.connection.QuicConnection
_on_retire_connection_id_delivery(delivery: QuicDeliveryState, sequence_number: int) -> None
at: aioquic.quic.connection.QuicConnection.__init__
self._quic_logger = configuration.quic_logger
at: aioquic.quic.packet
QuicFrameType(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
QuicFrameType(x: Union[str, bytes, bytearray], base: int)
at: aioquic.quic.packet_builder
QuicPacketBuilder(*, host_cid: bytes, peer_cid: bytes, version: int, pad_first_datagram: bool=False, packet_number: int=0, peer_token: bytes=b"", quic_logger: Optional[QuicLogger]=None, spin_bit: bool=False)
at: aioquic.quic.packet_builder.QuicPacketBuilder
start_frame(frame_type: int, handler: Optional[QuicDeliveryHandler]=None, args: Sequence[Any]=[]) -> None
at: aioquic.quic.packet_builder.QuicPacketBuilder.__init__
self._packet: Optional[QuicSentPacket] = None
self.buffer = Buffer(PACKET_MAX_SIZE)
at: aioquic.quic.packet_builder.QuicPacketBuilder.end_packet
self._packet = None
at: aioquic.quic.packet_builder.QuicPacketBuilder.start_packet
self._packet = QuicSentPacket(
epoch=epoch,
in_flight=False,
is_ack_eliciting=False,
is_crypto_packet=False,
packet_number=self._packet_number,
packet_type=packet_type,
)
===========unchanged ref 1===========
at: aioquic.quic.packet_builder.QuicSentPacket
quic_logger_frames: List[Dict] = field(default_factory=list)
===========changed ref 0===========
# module: aioquic.quic.connection
class QuicConnection:
def _write_ping_frame(self, builder: QuicPacketBuilder, uids: List[int] = []):
builder.start_frame(QuicFrameType.PING, self._on_ping_delivery, (tuple(uids),))
# log frame
if self._quic_logger is not None:
- builder._packet.quic_logger_frames.append(
- self._quic_logger.encode_ping_frame()
- )
+ builder.quic_logger_frames.append(self._quic_logger.encode_ping_frame())
===========changed ref 1===========
# module: aioquic.quic.connection
class QuicConnection:
def _write_new_connection_id_frame(
self, builder: QuicPacketBuilder, connection_id: QuicConnectionId
) -> None:
builder.start_frame(
QuicFrameType.NEW_CONNECTION_ID,
self._on_new_connection_id_delivery,
(connection_id,),
)
frame = QuicNewConnectionIdFrame(
sequence_number=connection_id.sequence_number,
retire_prior_to=0, # FIXME
connection_id=connection_id.cid,
stateless_reset_token=connection_id.stateless_reset_token,
)
push_new_connection_id_frame(builder.buffer, frame)
connection_id.was_sent = True
self._events.append(events.ConnectionIdIssued(connection_id=connection_id.cid))
# log frame
if self._quic_logger is not None:
+ builder.quic_logger_frames.append(
- builder._packet.quic_logger_frames.append(
self._quic_logger.encode_new_connection_id_frame(frame)
)
===========changed ref 2===========
# module: aioquic.quic.connection
class QuicConnection:
def _write_crypto_frame(
self, builder: QuicPacketBuilder, space: QuicPacketSpace, stream: QuicStream
) -> None:
buf = builder.buffer
frame_overhead = 3 + size_uint_var(stream.next_send_offset)
frame = stream.get_frame(builder.remaining_space - frame_overhead)
if frame is not None:
builder.start_frame(
QuicFrameType.CRYPTO,
stream.on_data_delivery,
(frame.offset, frame.offset + len(frame.data)),
)
buf.push_uint_var(frame.offset)
buf.push_uint16(len(frame.data) | 0x4000)
buf.push_bytes(frame.data)
# log frame
if self._quic_logger is not None:
+ builder.quic_logger_frames.append(
- builder._packet.quic_logger_frames.append(
self._quic_logger.encode_crypto_frame(frame)
)
===========changed ref 3===========
# module: aioquic.quic.connection
class QuicConnection:
def _write_ack_frame(self, builder: QuicPacketBuilder, space: QuicPacketSpace):
builder.start_frame(
QuicFrameType.ACK,
self._on_ack_delivery,
(space, space.largest_received_packet),
)
push_ack_frame(builder.buffer, space.ack_queue, 0)
space.ack_at = None
# log frame
if self._quic_logger is not None:
+ builder.quic_logger_frames.append(
- builder._packet.quic_logger_frames.append(
self._quic_logger.encode_ack_frame(ranges=space.ack_queue, delay=0.0)
)
===========changed ref 4===========
# module: aioquic.quic.connection
class QuicConnection:
def _write_connection_limits(
self, builder: QuicPacketBuilder, space: QuicPacketSpace
) -> None:
# raise MAX_DATA if needed
if self._local_max_data_used > self._local_max_data * 0.75:
self._local_max_data *= 2
self._logger.debug("Local max_data raised to %d", self._local_max_data)
if self._local_max_data_sent != self._local_max_data:
builder.start_frame(QuicFrameType.MAX_DATA, self._on_max_data_delivery)
builder.buffer.push_uint_var(self._local_max_data)
self._local_max_data_sent = self._local_max_data
# log frame
if self._quic_logger is not None:
+ builder.quic_logger_frames.append(
- builder._packet.quic_logger_frames.append(
self._quic_logger.encode_max_data_frame(self._local_max_data)
)
|
aioquic.quic.connection/QuicConnection._write_stream_frame
|
Modified
|
aiortc~aioquic
|
f89f264ca7ff9bf69a5ec2c3550bb0ffa67db2da
|
[qlog] switch to draft-01
|
<31>:<add> builder.quic_logger_frames.append(
<del> builder._packet.quic_logger_frames.append(
|
# module: aioquic.quic.connection
class QuicConnection:
def _write_stream_frame(
self,
builder: QuicPacketBuilder,
space: QuicPacketSpace,
stream: QuicStream,
max_offset: int,
) -> int:
<0> buf = builder.buffer
<1>
<2> # the frame data size is constrained by our peer's MAX_DATA and
<3> # the space available in the current packet
<4> frame_overhead = (
<5> 3
<6> + size_uint_var(stream.stream_id)
<7> + (size_uint_var(stream.next_send_offset) if stream.next_send_offset else 0)
<8> )
<9> previous_send_highest = stream._send_highest
<10> frame = stream.get_frame(builder.remaining_space - frame_overhead, max_offset)
<11>
<12> if frame is not None:
<13> frame_type = QuicFrameType.STREAM_BASE | 2 # length
<14> if frame.offset:
<15> frame_type |= 4
<16> if frame.fin:
<17> frame_type |= 1
<18> builder.start_frame(
<19> frame_type,
<20> stream.on_data_delivery,
<21> (frame.offset, frame.offset + len(frame.data)),
<22> )
<23> buf.push_uint_var(stream.stream_id)
<24> if frame.offset:
<25> buf.push_uint_var(frame.offset)
<26> buf.push_uint16(len(frame.data) | 0x4000)
<27> buf.push_bytes(frame.data)
<28>
<29> # log frame
<30> if self._quic_logger is not None:
<31> builder._packet.quic_logger_frames.append(
<32> self._quic_logger.encode_stream_frame(
<33> frame, stream_id=stream.stream_id
<34> )
<35> )
<36>
<37> return stream._send_highest - previous_send_highest
<38> else:
<39> return 0
<40>
|
===========unchanged ref 0===========
at: aioquic._buffer.Buffer
push_bytes(value: bytes) -> None
push_uint16(value: int) -> None
push_uint_var(value: int) -> None
at: aioquic.buffer
size_uint_var(value: int) -> int
at: aioquic.quic.connection.QuicConnection.__init__
self._quic_logger = configuration.quic_logger
at: aioquic.quic.packet
QuicFrameType(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
QuicFrameType(x: Union[str, bytes, bytearray], base: int)
at: aioquic.quic.packet_builder
QuicPacketBuilder(*, host_cid: bytes, peer_cid: bytes, version: int, pad_first_datagram: bool=False, packet_number: int=0, peer_token: bytes=b"", quic_logger: Optional[QuicLogger]=None, spin_bit: bool=False)
at: aioquic.quic.packet_builder.QuicPacketBuilder
start_frame(frame_type: int, handler: Optional[QuicDeliveryHandler]=None, args: Sequence[Any]=[]) -> None
at: aioquic.quic.packet_builder.QuicPacketBuilder.__init__
self._packet: Optional[QuicSentPacket] = None
self.buffer = Buffer(PACKET_MAX_SIZE)
at: aioquic.quic.packet_builder.QuicPacketBuilder.end_packet
self._packet = None
at: aioquic.quic.packet_builder.QuicPacketBuilder.start_packet
self._packet = QuicSentPacket(
epoch=epoch,
in_flight=False,
is_ack_eliciting=False,
is_crypto_packet=False,
packet_number=self._packet_number,
packet_type=packet_type,
)
===========unchanged ref 1===========
at: aioquic.quic.packet_builder.QuicSentPacket
quic_logger_frames: List[Dict] = field(default_factory=list)
at: aioquic.quic.recovery
QuicPacketSpace()
at: aioquic.quic.stream
QuicStream(stream_id: Optional[int]=None, connection: Optional[Any]=None, max_stream_data_local: int=0, max_stream_data_remote: int=0)
at: aioquic.quic.stream.QuicStream
get_frame(max_size: int, max_offset: Optional[int]=None) -> Optional[QuicStreamFrame]
on_data_delivery(delivery: QuicDeliveryState, start: int, stop: int) -> None
at: aioquic.quic.stream.QuicStream.__init__
self._send_highest = 0
at: aioquic.quic.stream.QuicStream.get_frame
self._send_highest = stop
===========changed ref 0===========
# module: aioquic.quic.connection
class QuicConnection:
def _write_ping_frame(self, builder: QuicPacketBuilder, uids: List[int] = []):
builder.start_frame(QuicFrameType.PING, self._on_ping_delivery, (tuple(uids),))
# log frame
if self._quic_logger is not None:
- builder._packet.quic_logger_frames.append(
- self._quic_logger.encode_ping_frame()
- )
+ builder.quic_logger_frames.append(self._quic_logger.encode_ping_frame())
===========changed ref 1===========
# module: aioquic.quic.connection
class QuicConnection:
def _write_retire_connection_id_frame(
self, builder: QuicPacketBuilder, sequence_number: int
) -> None:
builder.start_frame(
QuicFrameType.RETIRE_CONNECTION_ID,
self._on_retire_connection_id_delivery,
(sequence_number,),
)
builder.buffer.push_uint_var(sequence_number)
# log frame
if self._quic_logger is not None:
+ builder.quic_logger_frames.append(
- builder._packet.quic_logger_frames.append(
self._quic_logger.encode_retire_connection_id_frame(sequence_number)
)
===========changed ref 2===========
# module: aioquic.quic.connection
class QuicConnection:
def _write_new_connection_id_frame(
self, builder: QuicPacketBuilder, connection_id: QuicConnectionId
) -> None:
builder.start_frame(
QuicFrameType.NEW_CONNECTION_ID,
self._on_new_connection_id_delivery,
(connection_id,),
)
frame = QuicNewConnectionIdFrame(
sequence_number=connection_id.sequence_number,
retire_prior_to=0, # FIXME
connection_id=connection_id.cid,
stateless_reset_token=connection_id.stateless_reset_token,
)
push_new_connection_id_frame(builder.buffer, frame)
connection_id.was_sent = True
self._events.append(events.ConnectionIdIssued(connection_id=connection_id.cid))
# log frame
if self._quic_logger is not None:
+ builder.quic_logger_frames.append(
- builder._packet.quic_logger_frames.append(
self._quic_logger.encode_new_connection_id_frame(frame)
)
===========changed ref 3===========
# module: aioquic.quic.connection
class QuicConnection:
def _write_crypto_frame(
self, builder: QuicPacketBuilder, space: QuicPacketSpace, stream: QuicStream
) -> None:
buf = builder.buffer
frame_overhead = 3 + size_uint_var(stream.next_send_offset)
frame = stream.get_frame(builder.remaining_space - frame_overhead)
if frame is not None:
builder.start_frame(
QuicFrameType.CRYPTO,
stream.on_data_delivery,
(frame.offset, frame.offset + len(frame.data)),
)
buf.push_uint_var(frame.offset)
buf.push_uint16(len(frame.data) | 0x4000)
buf.push_bytes(frame.data)
# log frame
if self._quic_logger is not None:
+ builder.quic_logger_frames.append(
- builder._packet.quic_logger_frames.append(
self._quic_logger.encode_crypto_frame(frame)
)
===========changed ref 4===========
# module: aioquic.quic.connection
class QuicConnection:
def _write_ack_frame(self, builder: QuicPacketBuilder, space: QuicPacketSpace):
builder.start_frame(
QuicFrameType.ACK,
self._on_ack_delivery,
(space, space.largest_received_packet),
)
push_ack_frame(builder.buffer, space.ack_queue, 0)
space.ack_at = None
# log frame
if self._quic_logger is not None:
+ builder.quic_logger_frames.append(
- builder._packet.quic_logger_frames.append(
self._quic_logger.encode_ack_frame(ranges=space.ack_queue, delay=0.0)
)
|
aioquic.quic.connection/QuicConnection._write_stream_limits
|
Modified
|
aiortc~aioquic
|
f89f264ca7ff9bf69a5ec2c3550bb0ffa67db2da
|
[qlog] switch to draft-01
|
<20>:<add> builder.quic_logger_frames.append(
<del> builder._packet.quic_logger_frames.append(
|
# module: aioquic.quic.connection
class QuicConnection:
def _write_stream_limits(
self, builder: QuicPacketBuilder, space: QuicPacketSpace, stream: QuicStream
) -> None:
<0> # raise MAX_STREAM_DATA if needed
<1> if stream._recv_highest > stream.max_stream_data_local * 0.75:
<2> stream.max_stream_data_local *= 2
<3> self._logger.debug(
<4> "Stream %d local max_stream_data raised to %d",
<5> stream.stream_id,
<6> stream.max_stream_data_local,
<7> )
<8> if stream.max_stream_data_local_sent != stream.max_stream_data_local:
<9> builder.start_frame(
<10> QuicFrameType.MAX_STREAM_DATA,
<11> self._on_max_stream_data_delivery,
<12> (stream,),
<13> )
<14> builder.buffer.push_uint_var(stream.stream_id)
<15> builder.buffer.push_uint_var(stream.max_stream_data_local)
<16> stream.max_stream_data_local_sent = stream.max_stream_data_local
<17>
<18> # log frame
<19> if self._quic_logger is not None:
<20> builder._packet.quic_logger_frames.append(
<21> self._quic_logger.encode_max_stream_data_frame(
<22> maximum=stream.max_stream_data_local, stream_id=stream.stream_id
<23> )
<24> )
<25>
|
===========unchanged ref 0===========
at: aioquic._buffer.Buffer
push_uint_var(value: int) -> None
at: aioquic.quic.connection.QuicConnection
_on_max_stream_data_delivery(delivery: QuicDeliveryState, stream: QuicStream) -> None
at: aioquic.quic.connection.QuicConnection.__init__
self._quic_logger = configuration.quic_logger
self._logger = QuicConnectionAdapter(
logger, {"host_cid": dump_cid(self.host_cid)}
)
at: aioquic.quic.packet
QuicFrameType(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
QuicFrameType(x: Union[str, bytes, bytearray], base: int)
at: aioquic.quic.packet_builder
QuicPacketBuilder(*, host_cid: bytes, peer_cid: bytes, version: int, pad_first_datagram: bool=False, packet_number: int=0, peer_token: bytes=b"", quic_logger: Optional[QuicLogger]=None, spin_bit: bool=False)
at: aioquic.quic.packet_builder.QuicPacketBuilder
start_frame(frame_type: int, handler: Optional[QuicDeliveryHandler]=None, args: Sequence[Any]=[]) -> None
at: aioquic.quic.packet_builder.QuicPacketBuilder.__init__
self._packet: Optional[QuicSentPacket] = None
self.buffer = Buffer(PACKET_MAX_SIZE)
at: aioquic.quic.packet_builder.QuicPacketBuilder.end_packet
self._packet = None
===========unchanged ref 1===========
at: aioquic.quic.packet_builder.QuicPacketBuilder.start_packet
self._packet = QuicSentPacket(
epoch=epoch,
in_flight=False,
is_ack_eliciting=False,
is_crypto_packet=False,
packet_number=self._packet_number,
packet_type=packet_type,
)
at: aioquic.quic.packet_builder.QuicSentPacket
quic_logger_frames: List[Dict] = field(default_factory=list)
at: aioquic.quic.recovery
QuicPacketSpace()
at: aioquic.quic.stream
QuicStream(stream_id: Optional[int]=None, connection: Optional[Any]=None, max_stream_data_local: int=0, max_stream_data_remote: int=0)
at: aioquic.quic.stream.QuicStream.__init__
self.max_stream_data_local = max_stream_data_local
self.max_stream_data_local_sent = max_stream_data_local
self._recv_highest = 0 # the highest offset ever seen
at: aioquic.quic.stream.QuicStream.add_frame
self._recv_highest = frame_end
===========changed ref 0===========
# module: aioquic.quic.connection
class QuicConnection:
def _write_ping_frame(self, builder: QuicPacketBuilder, uids: List[int] = []):
builder.start_frame(QuicFrameType.PING, self._on_ping_delivery, (tuple(uids),))
# log frame
if self._quic_logger is not None:
- builder._packet.quic_logger_frames.append(
- self._quic_logger.encode_ping_frame()
- )
+ builder.quic_logger_frames.append(self._quic_logger.encode_ping_frame())
===========changed ref 1===========
# module: aioquic.quic.connection
class QuicConnection:
def _write_retire_connection_id_frame(
self, builder: QuicPacketBuilder, sequence_number: int
) -> None:
builder.start_frame(
QuicFrameType.RETIRE_CONNECTION_ID,
self._on_retire_connection_id_delivery,
(sequence_number,),
)
builder.buffer.push_uint_var(sequence_number)
# log frame
if self._quic_logger is not None:
+ builder.quic_logger_frames.append(
- builder._packet.quic_logger_frames.append(
self._quic_logger.encode_retire_connection_id_frame(sequence_number)
)
===========changed ref 2===========
# module: aioquic.quic.connection
class QuicConnection:
def _write_new_connection_id_frame(
self, builder: QuicPacketBuilder, connection_id: QuicConnectionId
) -> None:
builder.start_frame(
QuicFrameType.NEW_CONNECTION_ID,
self._on_new_connection_id_delivery,
(connection_id,),
)
frame = QuicNewConnectionIdFrame(
sequence_number=connection_id.sequence_number,
retire_prior_to=0, # FIXME
connection_id=connection_id.cid,
stateless_reset_token=connection_id.stateless_reset_token,
)
push_new_connection_id_frame(builder.buffer, frame)
connection_id.was_sent = True
self._events.append(events.ConnectionIdIssued(connection_id=connection_id.cid))
# log frame
if self._quic_logger is not None:
+ builder.quic_logger_frames.append(
- builder._packet.quic_logger_frames.append(
self._quic_logger.encode_new_connection_id_frame(frame)
)
===========changed ref 3===========
# module: aioquic.quic.connection
class QuicConnection:
def _write_crypto_frame(
self, builder: QuicPacketBuilder, space: QuicPacketSpace, stream: QuicStream
) -> None:
buf = builder.buffer
frame_overhead = 3 + size_uint_var(stream.next_send_offset)
frame = stream.get_frame(builder.remaining_space - frame_overhead)
if frame is not None:
builder.start_frame(
QuicFrameType.CRYPTO,
stream.on_data_delivery,
(frame.offset, frame.offset + len(frame.data)),
)
buf.push_uint_var(frame.offset)
buf.push_uint16(len(frame.data) | 0x4000)
buf.push_bytes(frame.data)
# log frame
if self._quic_logger is not None:
+ builder.quic_logger_frames.append(
- builder._packet.quic_logger_frames.append(
self._quic_logger.encode_crypto_frame(frame)
)
===========changed ref 4===========
# module: aioquic.quic.connection
class QuicConnection:
def _write_ack_frame(self, builder: QuicPacketBuilder, space: QuicPacketSpace):
builder.start_frame(
QuicFrameType.ACK,
self._on_ack_delivery,
(space, space.largest_received_packet),
)
push_ack_frame(builder.buffer, space.ack_queue, 0)
space.ack_at = None
# log frame
if self._quic_logger is not None:
+ builder.quic_logger_frames.append(
- builder._packet.quic_logger_frames.append(
self._quic_logger.encode_ack_frame(ranges=space.ack_queue, delay=0.0)
)
|
aioquic.quic.connection/QuicConnection._write_streams_blocked_frame
|
Modified
|
aiortc~aioquic
|
f89f264ca7ff9bf69a5ec2c3550bb0ffa67db2da
|
[qlog] switch to draft-01
|
<5>:<add> builder.quic_logger_frames.append(
<del> builder._packet.quic_logger_frames.append(
|
# module: aioquic.quic.connection
class QuicConnection:
def _write_streams_blocked_frame(
self, builder: QuicPacketBuilder, frame_type: QuicFrameType, limit: int
) -> None:
<0> builder.start_frame(frame_type)
<1> builder.buffer.push_uint_var(limit)
<2>
<3> # log frame
<4> if self._quic_logger is not None:
<5> builder._packet.quic_logger_frames.append(
<6> self._quic_logger.encode_streams_blocked_frame(limit=limit)
<7> )
<8>
|
===========unchanged ref 0===========
at: aioquic._buffer.Buffer
push_uint_var(value: int) -> None
at: aioquic.quic.connection.QuicConnection.__init__
self._quic_logger = configuration.quic_logger
at: aioquic.quic.packet
QuicFrameType(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
QuicFrameType(x: Union[str, bytes, bytearray], base: int)
at: aioquic.quic.packet_builder
QuicPacketBuilder(*, host_cid: bytes, peer_cid: bytes, version: int, pad_first_datagram: bool=False, packet_number: int=0, peer_token: bytes=b"", quic_logger: Optional[QuicLogger]=None, spin_bit: bool=False)
at: aioquic.quic.packet_builder.QuicPacketBuilder
start_frame(frame_type: int, handler: Optional[QuicDeliveryHandler]=None, args: Sequence[Any]=[]) -> None
at: aioquic.quic.packet_builder.QuicPacketBuilder.__init__
self._packet: Optional[QuicSentPacket] = None
self.buffer = Buffer(PACKET_MAX_SIZE)
at: aioquic.quic.packet_builder.QuicPacketBuilder.end_packet
self._packet = None
at: aioquic.quic.packet_builder.QuicPacketBuilder.start_packet
self._packet = QuicSentPacket(
epoch=epoch,
in_flight=False,
is_ack_eliciting=False,
is_crypto_packet=False,
packet_number=self._packet_number,
packet_type=packet_type,
)
at: aioquic.quic.packet_builder.QuicSentPacket
quic_logger_frames: List[Dict] = field(default_factory=list)
===========changed ref 0===========
# module: aioquic.quic.connection
class QuicConnection:
def _write_ping_frame(self, builder: QuicPacketBuilder, uids: List[int] = []):
builder.start_frame(QuicFrameType.PING, self._on_ping_delivery, (tuple(uids),))
# log frame
if self._quic_logger is not None:
- builder._packet.quic_logger_frames.append(
- self._quic_logger.encode_ping_frame()
- )
+ builder.quic_logger_frames.append(self._quic_logger.encode_ping_frame())
===========changed ref 1===========
# module: aioquic.quic.connection
class QuicConnection:
def _write_retire_connection_id_frame(
self, builder: QuicPacketBuilder, sequence_number: int
) -> None:
builder.start_frame(
QuicFrameType.RETIRE_CONNECTION_ID,
self._on_retire_connection_id_delivery,
(sequence_number,),
)
builder.buffer.push_uint_var(sequence_number)
# log frame
if self._quic_logger is not None:
+ builder.quic_logger_frames.append(
- builder._packet.quic_logger_frames.append(
self._quic_logger.encode_retire_connection_id_frame(sequence_number)
)
===========changed ref 2===========
# module: aioquic.quic.connection
class QuicConnection:
def _write_stream_limits(
self, builder: QuicPacketBuilder, space: QuicPacketSpace, stream: QuicStream
) -> None:
# raise MAX_STREAM_DATA if needed
if stream._recv_highest > stream.max_stream_data_local * 0.75:
stream.max_stream_data_local *= 2
self._logger.debug(
"Stream %d local max_stream_data raised to %d",
stream.stream_id,
stream.max_stream_data_local,
)
if stream.max_stream_data_local_sent != stream.max_stream_data_local:
builder.start_frame(
QuicFrameType.MAX_STREAM_DATA,
self._on_max_stream_data_delivery,
(stream,),
)
builder.buffer.push_uint_var(stream.stream_id)
builder.buffer.push_uint_var(stream.max_stream_data_local)
stream.max_stream_data_local_sent = stream.max_stream_data_local
# log frame
if self._quic_logger is not None:
+ builder.quic_logger_frames.append(
- builder._packet.quic_logger_frames.append(
self._quic_logger.encode_max_stream_data_frame(
maximum=stream.max_stream_data_local, stream_id=stream.stream_id
)
)
===========changed ref 3===========
# module: aioquic.quic.connection
class QuicConnection:
def _write_new_connection_id_frame(
self, builder: QuicPacketBuilder, connection_id: QuicConnectionId
) -> None:
builder.start_frame(
QuicFrameType.NEW_CONNECTION_ID,
self._on_new_connection_id_delivery,
(connection_id,),
)
frame = QuicNewConnectionIdFrame(
sequence_number=connection_id.sequence_number,
retire_prior_to=0, # FIXME
connection_id=connection_id.cid,
stateless_reset_token=connection_id.stateless_reset_token,
)
push_new_connection_id_frame(builder.buffer, frame)
connection_id.was_sent = True
self._events.append(events.ConnectionIdIssued(connection_id=connection_id.cid))
# log frame
if self._quic_logger is not None:
+ builder.quic_logger_frames.append(
- builder._packet.quic_logger_frames.append(
self._quic_logger.encode_new_connection_id_frame(frame)
)
===========changed ref 4===========
# module: aioquic.quic.connection
class QuicConnection:
def _write_crypto_frame(
self, builder: QuicPacketBuilder, space: QuicPacketSpace, stream: QuicStream
) -> None:
buf = builder.buffer
frame_overhead = 3 + size_uint_var(stream.next_send_offset)
frame = stream.get_frame(builder.remaining_space - frame_overhead)
if frame is not None:
builder.start_frame(
QuicFrameType.CRYPTO,
stream.on_data_delivery,
(frame.offset, frame.offset + len(frame.data)),
)
buf.push_uint_var(frame.offset)
buf.push_uint16(len(frame.data) | 0x4000)
buf.push_bytes(frame.data)
# log frame
if self._quic_logger is not None:
+ builder.quic_logger_frames.append(
- builder._packet.quic_logger_frames.append(
self._quic_logger.encode_crypto_frame(frame)
)
===========changed ref 5===========
# module: aioquic.quic.connection
class QuicConnection:
def _write_ack_frame(self, builder: QuicPacketBuilder, space: QuicPacketSpace):
builder.start_frame(
QuicFrameType.ACK,
self._on_ack_delivery,
(space, space.largest_received_packet),
)
push_ack_frame(builder.buffer, space.ack_queue, 0)
space.ack_at = None
# log frame
if self._quic_logger is not None:
+ builder.quic_logger_frames.append(
- builder._packet.quic_logger_frames.append(
self._quic_logger.encode_ack_frame(ranges=space.ack_queue, delay=0.0)
)
|
examples.interop/test_version_negotiation
|
Modified
|
aiortc~aioquic
|
f89f264ca7ff9bf69a5ec2c3550bb0ffa67db2da
|
[qlog] switch to draft-01
|
<12>:<add> category == "transport"
<del> category == "TRANSPORT"
<13>:<add> and event == "packet_received"
<add> and data["packet_type"] == "version_negotiation"
<del> and event == "PACKET_RECEIVED"
<14>:<del> and data["packet_type"] == "VERSION_NEGOTIATION"
|
# module: examples.interop
def test_version_negotiation(server: Server, configuration: QuicConfiguration):
<0> configuration.supported_versions = [0x1A2A3A4A, QuicProtocolVersion.DRAFT_22]
<1>
<2> async with connect(
<3> server.host, server.port, configuration=configuration
<4> ) as protocol:
<5> await protocol.ping()
<6>
<7> # check log
<8> for stamp, category, event, data in configuration.quic_logger.to_dict()[
<9> "traces"
<10> ][0]["events"]:
<11> if (
<12> category == "TRANSPORT"
<13> and event == "PACKET_RECEIVED"
<14> and data["packet_type"] == "VERSION_NEGOTIATION"
<15> ):
<16> server.result |= Result.V
<17>
|
===========unchanged ref 0===========
at: aioquic.asyncio.client
connect(host: str, port: int, *, configuration: Optional[QuicConfiguration]=None, create_protocol: Optional[Callable]=QuicConnectionProtocol, session_ticket_handler: Optional[SessionTicketHandler]=None, stream_handler: Optional[QuicStreamHandler]=None) -> AsyncGenerator[QuicConnectionProtocol, None]
connect(*args, **kwds)
at: aioquic.asyncio.protocol.QuicConnectionProtocol
ping() -> None
at: aioquic.quic.configuration
QuicConfiguration(alpn_protocols: Optional[List[str]]=None, certificate: Any=None, idle_timeout: float=60.0, is_client: bool=True, private_key: Any=None, quic_logger: Optional[QuicLogger]=None, secrets_log_file: TextIO=None, server_name: Optional[str]=None, session_ticket: Optional[SessionTicket]=None, supported_versions: List[int]=field(
default_factory=lambda: [QuicProtocolVersion.DRAFT_22]
))
at: aioquic.quic.configuration.QuicConfiguration
alpn_protocols: Optional[List[str]] = None
certificate: Any = None
idle_timeout: float = 60.0
is_client: bool = True
private_key: Any = None
quic_logger: Optional[QuicLogger] = None
secrets_log_file: TextIO = None
server_name: Optional[str] = None
session_ticket: Optional[SessionTicket] = None
supported_versions: List[int] = field(
default_factory=lambda: [QuicProtocolVersion.DRAFT_22]
)
at: aioquic.quic.logger.QuicLogger
to_dict() -> Dict[str, Any]
===========unchanged ref 1===========
at: aioquic.quic.packet
QuicProtocolVersion(x: Union[str, bytes, bytearray], base: int)
QuicProtocolVersion(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
at: examples.interop
Server(name: str, host: str, port: int=4433, http3: bool=True, retry_port: Optional[int]=4434, path: str="/", result: Result=field(default_factory=lambda: Result(0)))
at: examples.interop.Server
name: str
host: str
port: int = 4433
http3: bool = True
retry_port: Optional[int] = 4434
path: str = "/"
result: Result = field(default_factory=lambda: Result(0))
===========changed ref 0===========
# module: aioquic.quic.logger
class QuicLogger:
def to_dict(self) -> Dict[str, Any]:
"""
Return the trace as a dictionary which can be written as JSON.
"""
traces = []
if self._events:
reference_time = self._events[0][0]
trace = {
"common_fields": {"reference_time": "%d" % (reference_time * 1000)},
+ "event_fields": ["relative_time", "category", "event_type", "data"],
- "event_fields": ["relative_time", "CATEGORY", "EVENT_TYPE", "DATA"],
"events": list(
map(
lambda event: (
"%d" % ((event[0] - reference_time) * 1000),
event[1],
event[2],
event[3],
),
self._events,
)
),
"vantage_point": self._vantage_point,
}
traces.append(trace)
+ return {"qlog_version": "draft-01", "traces": traces}
- return {"qlog_version": "draft-00", "traces": traces}
===========changed ref 1===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_ping_frame(self) -> Dict:
+ return {"frame_type": "ping"}
- return {"frame_type": "PING"}
===========changed ref 2===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_padding_frame(self) -> Dict:
+ return {"frame_type": "padding"}
- return {"frame_type": "PADDING"}
===========changed ref 3===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_data_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_data", "maximum": str(maximum)}
- return {"frame_type": "MAX_DATA", "maximum": str(maximum)}
===========changed ref 4===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_streams_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_streams", "maximum": str(maximum)}
- return {"frame_type": "MAX_STREAMS", "maximum": str(maximum)}
===========changed ref 5===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_data_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "data_blocked", "limit": str(limit)}
- return {"frame_type": "DATA_BLOCKED", "limit": str(limit)}
===========changed ref 6===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_streams_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "streams_blocked", "limit": str(limit)}
- return {"frame_type": "STREAMS_BLOCKED", "limit": str(limit)}
===========changed ref 7===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_path_response_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "path_response"}
- return {"data": hexdump(data), "frame_type": "PATH_RESPONSE"}
===========changed ref 8===========
# module: aioquic.quic.logger
class QuicLogger:
def start_trace(self, is_client: bool) -> None:
+ self._vantage_point["type"] = "client" if is_client else "server"
- self._vantage_point["type"] = "CLIENT" if is_client else "SERVER"
===========changed ref 9===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_path_challenge_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "path_challenge"}
- return {"data": hexdump(data), "frame_type": "PATH_CHALLENGE"}
===========changed ref 10===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_retire_connection_id_frame(self, sequence_number: int) -> Dict:
return {
+ "frame_type": "retire_connection_id",
- "frame_type": "RETIRE_CONNECTION_ID",
"sequence_number": str(sequence_number),
}
===========changed ref 11===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_new_token_frame(self, token: bytes) -> Dict:
return {
+ "frame_type": "new_token",
- "frame_type": "NEW_TOKEN",
"length": str(len(token)),
"token": hexdump(token),
}
===========changed ref 12===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_stop_sending_frame(self, error_code: int, stream_id: int) -> Dict:
return {
+ "frame_type": "stop_sending",
- "frame_type": "STOP_SENDING",
"id": str(stream_id),
"error_code": error_code,
}
|
examples.interop/test_stateless_retry
|
Modified
|
aiortc~aioquic
|
f89f264ca7ff9bf69a5ec2c3550bb0ffa67db2da
|
[qlog] switch to draft-01
|
<10>:<add> category == "transport"
<del> category == "TRANSPORT"
<11>:<add> and event == "packet_received"
<del> and event == "PACKET_RECEIVED"
<12>:<add> and data["packet_type"] == "retry"
<del> and data["packet_type"] == "RETRY"
|
# module: examples.interop
def test_stateless_retry(server: Server, configuration: QuicConfiguration):
<0> async with connect(
<1> server.host, server.retry_port, configuration=configuration
<2> ) as protocol:
<3> await protocol.ping()
<4>
<5> # check log
<6> for stamp, category, event, data in configuration.quic_logger.to_dict()[
<7> "traces"
<8> ][0]["events"]:
<9> if (
<10> category == "TRANSPORT"
<11> and event == "PACKET_RECEIVED"
<12> and data["packet_type"] == "RETRY"
<13> ):
<14> server.result |= Result.S
<15>
|
===========unchanged ref 0===========
at: aioquic.asyncio.client
connect(host: str, port: int, *, configuration: Optional[QuicConfiguration]=None, create_protocol: Optional[Callable]=QuicConnectionProtocol, session_ticket_handler: Optional[SessionTicketHandler]=None, stream_handler: Optional[QuicStreamHandler]=None) -> AsyncGenerator[QuicConnectionProtocol, None]
connect(*args, **kwds)
at: aioquic.asyncio.protocol.QuicConnectionProtocol
ping() -> None
at: aioquic.quic.configuration
QuicConfiguration(alpn_protocols: Optional[List[str]]=None, certificate: Any=None, idle_timeout: float=60.0, is_client: bool=True, private_key: Any=None, quic_logger: Optional[QuicLogger]=None, secrets_log_file: TextIO=None, server_name: Optional[str]=None, session_ticket: Optional[SessionTicket]=None, supported_versions: List[int]=field(
default_factory=lambda: [QuicProtocolVersion.DRAFT_22]
))
at: aioquic.quic.configuration.QuicConfiguration
quic_logger: Optional[QuicLogger] = None
at: aioquic.quic.logger.QuicLogger
to_dict() -> Dict[str, Any]
at: examples.interop
Server(name: str, host: str, port: int=4433, http3: bool=True, retry_port: Optional[int]=4434, path: str="/", result: Result=field(default_factory=lambda: Result(0)))
at: examples.interop.Server
host: str
retry_port: Optional[int] = 4434
===========changed ref 0===========
# module: aioquic.quic.logger
class QuicLogger:
def to_dict(self) -> Dict[str, Any]:
"""
Return the trace as a dictionary which can be written as JSON.
"""
traces = []
if self._events:
reference_time = self._events[0][0]
trace = {
"common_fields": {"reference_time": "%d" % (reference_time * 1000)},
+ "event_fields": ["relative_time", "category", "event_type", "data"],
- "event_fields": ["relative_time", "CATEGORY", "EVENT_TYPE", "DATA"],
"events": list(
map(
lambda event: (
"%d" % ((event[0] - reference_time) * 1000),
event[1],
event[2],
event[3],
),
self._events,
)
),
"vantage_point": self._vantage_point,
}
traces.append(trace)
+ return {"qlog_version": "draft-01", "traces": traces}
- return {"qlog_version": "draft-00", "traces": traces}
===========changed ref 1===========
# module: examples.interop
def test_version_negotiation(server: Server, configuration: QuicConfiguration):
configuration.supported_versions = [0x1A2A3A4A, QuicProtocolVersion.DRAFT_22]
async with connect(
server.host, server.port, configuration=configuration
) as protocol:
await protocol.ping()
# check log
for stamp, category, event, data in configuration.quic_logger.to_dict()[
"traces"
][0]["events"]:
if (
+ category == "transport"
- category == "TRANSPORT"
+ and event == "packet_received"
+ and data["packet_type"] == "version_negotiation"
- and event == "PACKET_RECEIVED"
- and data["packet_type"] == "VERSION_NEGOTIATION"
):
server.result |= Result.V
===========changed ref 2===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_ping_frame(self) -> Dict:
+ return {"frame_type": "ping"}
- return {"frame_type": "PING"}
===========changed ref 3===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_padding_frame(self) -> Dict:
+ return {"frame_type": "padding"}
- return {"frame_type": "PADDING"}
===========changed ref 4===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_data_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_data", "maximum": str(maximum)}
- return {"frame_type": "MAX_DATA", "maximum": str(maximum)}
===========changed ref 5===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_streams_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_streams", "maximum": str(maximum)}
- return {"frame_type": "MAX_STREAMS", "maximum": str(maximum)}
===========changed ref 6===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_data_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "data_blocked", "limit": str(limit)}
- return {"frame_type": "DATA_BLOCKED", "limit": str(limit)}
===========changed ref 7===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_streams_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "streams_blocked", "limit": str(limit)}
- return {"frame_type": "STREAMS_BLOCKED", "limit": str(limit)}
===========changed ref 8===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_path_response_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "path_response"}
- return {"data": hexdump(data), "frame_type": "PATH_RESPONSE"}
===========changed ref 9===========
# module: aioquic.quic.logger
class QuicLogger:
def start_trace(self, is_client: bool) -> None:
+ self._vantage_point["type"] = "client" if is_client else "server"
- self._vantage_point["type"] = "CLIENT" if is_client else "SERVER"
===========changed ref 10===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_path_challenge_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "path_challenge"}
- return {"data": hexdump(data), "frame_type": "PATH_CHALLENGE"}
===========changed ref 11===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_retire_connection_id_frame(self, sequence_number: int) -> Dict:
return {
+ "frame_type": "retire_connection_id",
- "frame_type": "RETIRE_CONNECTION_ID",
"sequence_number": str(sequence_number),
}
===========changed ref 12===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_new_token_frame(self, token: bytes) -> Dict:
return {
+ "frame_type": "new_token",
- "frame_type": "NEW_TOKEN",
"length": str(len(token)),
"token": hexdump(token),
}
===========changed ref 13===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_stop_sending_frame(self, error_code: int, stream_id: int) -> Dict:
return {
+ "frame_type": "stop_sending",
- "frame_type": "STOP_SENDING",
"id": str(stream_id),
"error_code": error_code,
}
|
examples.interop/test_migration
|
Modified
|
aiortc~aioquic
|
f89f264ca7ff9bf69a5ec2c3550bb0ffa67db2da
|
[qlog] switch to draft-01
|
<20>:<add> category == "transport"
<del> category == "TRANSPORT"
<21>:<add> and event == "packet_received"
<del> and event == "PACKET_RECEIVED"
|
# module: examples.interop
def test_migration(server: Server, configuration: QuicConfiguration):
<0> async with connect(
<1> server.host, server.port, configuration=configuration
<2> ) as protocol:
<3> # cause some traffic
<4> await protocol.ping()
<5>
<6> # change connection ID and replace transport
<7> protocol.change_connection_id()
<8> protocol._transport.close()
<9> await loop.create_datagram_endpoint(lambda: protocol, local_addr=("::", 0))
<10>
<11> # cause more traffic
<12> await protocol.ping()
<13>
<14> # check log
<15> dcids = set()
<16> for stamp, category, event, data in configuration.quic_logger.to_dict()[
<17> "traces"
<18> ][0]["events"]:
<19> if (
<20> category == "TRANSPORT"
<21> and event == "PACKET_RECEIVED"
<22> and data["packet_type"] == "1RTT"
<23> ):
<24> dcids.add(data["header"]["dcid"])
<25> if len(dcids) == 2:
<26> server.result |= Result.M
<27>
|
===========unchanged ref 0===========
at: aioquic.asyncio.client
connect(host: str, port: int, *, configuration: Optional[QuicConfiguration]=None, create_protocol: Optional[Callable]=QuicConnectionProtocol, session_ticket_handler: Optional[SessionTicketHandler]=None, stream_handler: Optional[QuicStreamHandler]=None) -> AsyncGenerator[QuicConnectionProtocol, None]
connect(*args, **kwds)
at: aioquic.asyncio.protocol.QuicConnectionProtocol
change_connection_id() -> None
ping() -> None
at: aioquic.asyncio.protocol.QuicConnectionProtocol.__init__
self._transport: Optional[asyncio.DatagramTransport] = None
at: aioquic.asyncio.protocol.QuicConnectionProtocol.connection_made
self._transport = cast(asyncio.DatagramTransport, transport)
at: aioquic.quic.configuration
QuicConfiguration(alpn_protocols: Optional[List[str]]=None, certificate: Any=None, idle_timeout: float=60.0, is_client: bool=True, private_key: Any=None, quic_logger: Optional[QuicLogger]=None, secrets_log_file: TextIO=None, server_name: Optional[str]=None, session_ticket: Optional[SessionTicket]=None, supported_versions: List[int]=field(
default_factory=lambda: [QuicProtocolVersion.DRAFT_22]
))
at: aioquic.quic.configuration.QuicConfiguration
quic_logger: Optional[QuicLogger] = None
at: aioquic.quic.logger.QuicLogger
to_dict() -> Dict[str, Any]
===========unchanged ref 1===========
at: asyncio.events.AbstractEventLoop
create_datagram_endpoint(protocol_factory: _ProtocolFactory, local_addr: Optional[Tuple[str, int]]=..., remote_addr: Optional[Tuple[str, int]]=..., *, family: int=..., proto: int=..., flags: int=..., reuse_address: Optional[bool]=..., reuse_port: Optional[bool]=..., allow_broadcast: Optional[bool]=..., sock: Optional[socket]=...) -> _TransProtPair
at: asyncio.transports.BaseTransport
__slots__ = ('_extra',)
close() -> None
at: examples.interop
Server(name: str, host: str, port: int=4433, http3: bool=True, retry_port: Optional[int]=4434, path: str="/", result: Result=field(default_factory=lambda: Result(0)))
loop = asyncio.get_event_loop()
at: examples.interop.Server
host: str
port: int = 4433
===========changed ref 0===========
# module: aioquic.quic.logger
class QuicLogger:
def to_dict(self) -> Dict[str, Any]:
"""
Return the trace as a dictionary which can be written as JSON.
"""
traces = []
if self._events:
reference_time = self._events[0][0]
trace = {
"common_fields": {"reference_time": "%d" % (reference_time * 1000)},
+ "event_fields": ["relative_time", "category", "event_type", "data"],
- "event_fields": ["relative_time", "CATEGORY", "EVENT_TYPE", "DATA"],
"events": list(
map(
lambda event: (
"%d" % ((event[0] - reference_time) * 1000),
event[1],
event[2],
event[3],
),
self._events,
)
),
"vantage_point": self._vantage_point,
}
traces.append(trace)
+ return {"qlog_version": "draft-01", "traces": traces}
- return {"qlog_version": "draft-00", "traces": traces}
===========changed ref 1===========
# module: examples.interop
def test_stateless_retry(server: Server, configuration: QuicConfiguration):
async with connect(
server.host, server.retry_port, configuration=configuration
) as protocol:
await protocol.ping()
# check log
for stamp, category, event, data in configuration.quic_logger.to_dict()[
"traces"
][0]["events"]:
if (
+ category == "transport"
- category == "TRANSPORT"
+ and event == "packet_received"
- and event == "PACKET_RECEIVED"
+ and data["packet_type"] == "retry"
- and data["packet_type"] == "RETRY"
):
server.result |= Result.S
===========changed ref 2===========
# module: examples.interop
def test_version_negotiation(server: Server, configuration: QuicConfiguration):
configuration.supported_versions = [0x1A2A3A4A, QuicProtocolVersion.DRAFT_22]
async with connect(
server.host, server.port, configuration=configuration
) as protocol:
await protocol.ping()
# check log
for stamp, category, event, data in configuration.quic_logger.to_dict()[
"traces"
][0]["events"]:
if (
+ category == "transport"
- category == "TRANSPORT"
+ and event == "packet_received"
+ and data["packet_type"] == "version_negotiation"
- and event == "PACKET_RECEIVED"
- and data["packet_type"] == "VERSION_NEGOTIATION"
):
server.result |= Result.V
===========changed ref 3===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_ping_frame(self) -> Dict:
+ return {"frame_type": "ping"}
- return {"frame_type": "PING"}
===========changed ref 4===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_padding_frame(self) -> Dict:
+ return {"frame_type": "padding"}
- return {"frame_type": "PADDING"}
===========changed ref 5===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_data_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_data", "maximum": str(maximum)}
- return {"frame_type": "MAX_DATA", "maximum": str(maximum)}
===========changed ref 6===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_streams_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_streams", "maximum": str(maximum)}
- return {"frame_type": "MAX_STREAMS", "maximum": str(maximum)}
===========changed ref 7===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_data_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "data_blocked", "limit": str(limit)}
- return {"frame_type": "DATA_BLOCKED", "limit": str(limit)}
===========changed ref 8===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_streams_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "streams_blocked", "limit": str(limit)}
- return {"frame_type": "STREAMS_BLOCKED", "limit": str(limit)}
===========changed ref 9===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_path_response_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "path_response"}
- return {"data": hexdump(data), "frame_type": "PATH_RESPONSE"}
===========changed ref 10===========
# module: aioquic.quic.logger
class QuicLogger:
def start_trace(self, is_client: bool) -> None:
+ self._vantage_point["type"] = "client" if is_client else "server"
- self._vantage_point["type"] = "CLIENT" if is_client else "SERVER"
|
examples.interop/test_spin_bit
|
Modified
|
aiortc~aioquic
|
f89f264ca7ff9bf69a5ec2c3550bb0ffa67db2da
|
[qlog] switch to draft-01
|
<11>:<add> if category == "connectivity" and event == "spin_bit_update":
<del> if category == "CONNECTIVITY" and event == "SPIN_BIT_UPDATE":
|
# module: examples.interop
def test_spin_bit(server: Server, configuration: QuicConfiguration):
<0> async with connect(
<1> server.host, server.port, configuration=configuration
<2> ) as protocol:
<3> for i in range(5):
<4> await protocol.ping()
<5>
<6> # check log
<7> spin_bits = set()
<8> for stamp, category, event, data in configuration.quic_logger.to_dict()[
<9> "traces"
<10> ][0]["events"]:
<11> if category == "CONNECTIVITY" and event == "SPIN_BIT_UPDATE":
<12> spin_bits.add(data["state"])
<13> if len(spin_bits) == 2:
<14> server.result |= Result.P
<15>
|
===========unchanged ref 0===========
at: aioquic.asyncio.client
connect(host: str, port: int, *, configuration: Optional[QuicConfiguration]=None, create_protocol: Optional[Callable]=QuicConnectionProtocol, session_ticket_handler: Optional[SessionTicketHandler]=None, stream_handler: Optional[QuicStreamHandler]=None) -> AsyncGenerator[QuicConnectionProtocol, None]
connect(*args, **kwds)
at: aioquic.asyncio.protocol.QuicConnectionProtocol
ping() -> None
at: aioquic.quic.configuration
QuicConfiguration(alpn_protocols: Optional[List[str]]=None, certificate: Any=None, idle_timeout: float=60.0, is_client: bool=True, private_key: Any=None, quic_logger: Optional[QuicLogger]=None, secrets_log_file: TextIO=None, server_name: Optional[str]=None, session_ticket: Optional[SessionTicket]=None, supported_versions: List[int]=field(
default_factory=lambda: [QuicProtocolVersion.DRAFT_22]
))
at: aioquic.quic.configuration.QuicConfiguration
quic_logger: Optional[QuicLogger] = None
at: aioquic.quic.logger.QuicLogger
to_dict() -> Dict[str, Any]
at: examples.interop
Server(name: str, host: str, port: int=4433, http3: bool=True, retry_port: Optional[int]=4434, path: str="/", result: Result=field(default_factory=lambda: Result(0)))
at: examples.interop.Server
host: str
port: int = 4433
===========changed ref 0===========
# module: aioquic.quic.logger
class QuicLogger:
def to_dict(self) -> Dict[str, Any]:
"""
Return the trace as a dictionary which can be written as JSON.
"""
traces = []
if self._events:
reference_time = self._events[0][0]
trace = {
"common_fields": {"reference_time": "%d" % (reference_time * 1000)},
+ "event_fields": ["relative_time", "category", "event_type", "data"],
- "event_fields": ["relative_time", "CATEGORY", "EVENT_TYPE", "DATA"],
"events": list(
map(
lambda event: (
"%d" % ((event[0] - reference_time) * 1000),
event[1],
event[2],
event[3],
),
self._events,
)
),
"vantage_point": self._vantage_point,
}
traces.append(trace)
+ return {"qlog_version": "draft-01", "traces": traces}
- return {"qlog_version": "draft-00", "traces": traces}
===========changed ref 1===========
# module: examples.interop
def test_migration(server: Server, configuration: QuicConfiguration):
async with connect(
server.host, server.port, configuration=configuration
) as protocol:
# cause some traffic
await protocol.ping()
# change connection ID and replace transport
protocol.change_connection_id()
protocol._transport.close()
await loop.create_datagram_endpoint(lambda: protocol, local_addr=("::", 0))
# cause more traffic
await protocol.ping()
# check log
dcids = set()
for stamp, category, event, data in configuration.quic_logger.to_dict()[
"traces"
][0]["events"]:
if (
+ category == "transport"
- category == "TRANSPORT"
+ and event == "packet_received"
- and event == "PACKET_RECEIVED"
and data["packet_type"] == "1RTT"
):
dcids.add(data["header"]["dcid"])
if len(dcids) == 2:
server.result |= Result.M
===========changed ref 2===========
# module: examples.interop
def test_stateless_retry(server: Server, configuration: QuicConfiguration):
async with connect(
server.host, server.retry_port, configuration=configuration
) as protocol:
await protocol.ping()
# check log
for stamp, category, event, data in configuration.quic_logger.to_dict()[
"traces"
][0]["events"]:
if (
+ category == "transport"
- category == "TRANSPORT"
+ and event == "packet_received"
- and event == "PACKET_RECEIVED"
+ and data["packet_type"] == "retry"
- and data["packet_type"] == "RETRY"
):
server.result |= Result.S
===========changed ref 3===========
# module: examples.interop
def test_version_negotiation(server: Server, configuration: QuicConfiguration):
configuration.supported_versions = [0x1A2A3A4A, QuicProtocolVersion.DRAFT_22]
async with connect(
server.host, server.port, configuration=configuration
) as protocol:
await protocol.ping()
# check log
for stamp, category, event, data in configuration.quic_logger.to_dict()[
"traces"
][0]["events"]:
if (
+ category == "transport"
- category == "TRANSPORT"
+ and event == "packet_received"
+ and data["packet_type"] == "version_negotiation"
- and event == "PACKET_RECEIVED"
- and data["packet_type"] == "VERSION_NEGOTIATION"
):
server.result |= Result.V
===========changed ref 4===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_ping_frame(self) -> Dict:
+ return {"frame_type": "ping"}
- return {"frame_type": "PING"}
===========changed ref 5===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_padding_frame(self) -> Dict:
+ return {"frame_type": "padding"}
- return {"frame_type": "PADDING"}
===========changed ref 6===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_data_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_data", "maximum": str(maximum)}
- return {"frame_type": "MAX_DATA", "maximum": str(maximum)}
===========changed ref 7===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_max_streams_frame(self, maximum: int) -> Dict:
+ return {"frame_type": "max_streams", "maximum": str(maximum)}
- return {"frame_type": "MAX_STREAMS", "maximum": str(maximum)}
===========changed ref 8===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_data_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "data_blocked", "limit": str(limit)}
- return {"frame_type": "DATA_BLOCKED", "limit": str(limit)}
===========changed ref 9===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_streams_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "streams_blocked", "limit": str(limit)}
- return {"frame_type": "STREAMS_BLOCKED", "limit": str(limit)}
===========changed ref 10===========
# module: aioquic.quic.logger
class QuicLogger:
def encode_path_response_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "path_response"}
- return {"data": hexdump(data), "frame_type": "PATH_RESPONSE"}
|
examples.interop/run
|
Modified
|
aiortc~aioquic
|
87679e4e43eee330df7da34bc19d1b12cd13ef08
|
[interop] add an option to store QLOG files
|
<19>:<add>
<add> if quic_log:
<add> with open("%s-%s.qlog" % (server.name, test_name), "w") as logger_fp:
<add> json.dump(configuration.quic_logger.to_dict(), logger_fp, indent=4)
<add>
|
# module: examples.interop
+ def run(servers, tests, quic_log=False, secrets_log_file=None) -> None:
- def run(servers, tests, secrets_log_file=None) -> None:
<0> for server in servers:
<1> for test_name, test_func in tests:
<2> print("\n=== %s %s ===\n" % (server.name, test_name))
<3> configuration = QuicConfiguration(
<4> alpn_protocols=["hq-22", "h3-22"],
<5> is_client=True,
<6> quic_logger=QuicLogger(),
<7> secrets_log_file=secrets_log_file,
<8> )
<9> if test_name == "test_throughput":
<10> timeout = 60
<11> else:
<12> timeout = 5
<13> try:
<14> await asyncio.wait_for(
<15> test_func(server, configuration), timeout=timeout
<16> )
<17> except Exception as exc:
<18> print(exc)
<19> print("")
<20> print_result(server)
<21>
<22> # print summary
<23> if len(servers) > 1:
<24> print("SUMMARY")
<25> for server in servers:
<26> print_result(server)
<27>
|
===========unchanged ref 0===========
at: aioquic.quic.configuration
QuicConfiguration(alpn_protocols: Optional[List[str]]=None, certificate: Any=None, idle_timeout: float=60.0, is_client: bool=True, private_key: Any=None, quic_logger: Optional[QuicLogger]=None, secrets_log_file: TextIO=None, server_name: Optional[str]=None, session_ticket: Optional[SessionTicket]=None, supported_versions: List[int]=field(
default_factory=lambda: [QuicProtocolVersion.DRAFT_22]
))
at: aioquic.quic.configuration.QuicConfiguration
alpn_protocols: Optional[List[str]] = None
certificate: Any = None
idle_timeout: float = 60.0
is_client: bool = True
private_key: Any = None
quic_logger: Optional[QuicLogger] = None
secrets_log_file: TextIO = None
server_name: Optional[str] = None
session_ticket: Optional[SessionTicket] = None
supported_versions: List[int] = field(
default_factory=lambda: [QuicProtocolVersion.DRAFT_22]
)
at: aioquic.quic.logger
QuicLogger()
at: aioquic.quic.logger.QuicLogger
to_dict() -> Dict[str, Any]
at: asyncio.tasks
wait_for(fut: _FutureT[_T], timeout: Optional[float], *, loop: Optional[AbstractEventLoop]=...) -> Future[_T]
at: examples.interop
print_result(server: Server) -> None
at: examples.interop.Server
name: str
host: str
port: int = 4433
http3: bool = True
retry_port: Optional[int] = 4434
path: str = "/"
result: Result = field(default_factory=lambda: Result(0))
===========unchanged ref 1===========
at: json
dump(obj: Any, fp: IO[str], *, skipkeys: bool=..., ensure_ascii: bool=..., check_circular: bool=..., allow_nan: bool=..., cls: Optional[Type[JSONEncoder]]=..., indent: Union[None, int, str]=..., separators: Optional[Tuple[str, str]]=..., default: Optional[Callable[[Any], Any]]=..., sort_keys: bool=..., **kwds: Any) -> None
|
aioquic.quic.connection/QuicConnection.change_connection_id
|
Modified
|
aiortc~aioquic
|
d65f3a5782c3f85c17dbcff139c619b94d9d1d71
|
[logging] reduce level of CID / network path messages
|
<6>:<add> self._logger.debug(
<add> "Retiring %s (%d)", dump_cid(self._peer_cid), self._peer_cid_seq
<add> )
<12>:<add> self._logger.debug(
<del> self._logger.info(
|
# module: aioquic.quic.connection
class QuicConnection:
def change_connection_id(self) -> None:
<0> """
<1> Switch to the next available connection ID and retire
<2> the previous one.
<3> """
<4> if self._peer_cid_available:
<5> # retire previous CID
<6> self._retire_connection_ids.append(self._peer_cid_seq)
<7>
<8> # assign new CID
<9> connection_id = self._peer_cid_available.pop(0)
<10> self._peer_cid_seq = connection_id.sequence_number
<11> self._peer_cid = connection_id.cid
<12> self._logger.info(
<13> "Migrating to %s (%d)", dump_cid(self._peer_cid), self._peer_cid_seq
<14> )
<15>
|
===========unchanged ref 0===========
at: aioquic.quic.connection
dump_cid(cid: bytes) -> str
at: aioquic.quic.connection.QuicConnection.__init__
self._logger = QuicConnectionAdapter(
logger, {"host_cid": dump_cid(self.host_cid)}
)
self._peer_cid = os.urandom(8)
self._peer_cid_seq: Optional[int] = None
self._peer_cid_available: List[QuicConnectionId] = []
self._retire_connection_ids: List[int] = []
at: aioquic.quic.connection.QuicConnection.receive_datagram
self._peer_cid = header.source_cid
self._peer_cid_seq = 0
at: aioquic.quic.connection.QuicConnectionId
cid: bytes
sequence_number: int
stateless_reset_token: bytes = b""
was_sent: bool = False
at: logging.LoggerAdapter
logger: Logger
extra: Mapping[str, Any]
debug(msg: Any, *args: Any, exc_info: _ExcInfoType=..., stack_info: bool=..., extra: Optional[Dict[str, Any]]=..., **kwargs: Any) -> None
|
aioquic.quic.connection/QuicConnection._find_network_path
|
Modified
|
aiortc~aioquic
|
d65f3a5782c3f85c17dbcff139c619b94d9d1d71
|
[logging] reduce level of CID / network path messages
|
<7>:<add> self._logger.debug("Network path %s discovered", network_path.addr)
<del> self._logger.info("Network path %s discovered", network_path.addr)
|
# module: aioquic.quic.connection
class QuicConnection:
def _find_network_path(self, addr: NetworkAddress) -> QuicNetworkPath:
<0> # check existing network paths
<1> for idx, network_path in enumerate(self._network_paths):
<2> if network_path.addr == addr:
<3> return network_path
<4>
<5> # new network path
<6> network_path = QuicNetworkPath(addr)
<7> self._logger.info("Network path %s discovered", network_path.addr)
<8> return network_path
<9>
|
===========unchanged ref 0===========
at: aioquic.quic.connection
NetworkAddress = Any
QuicNetworkPath(addr: NetworkAddress, bytes_received: int=0, bytes_sent: int=0, is_validated: bool=False, local_challenge: Optional[bytes]=None, remote_challenge: Optional[bytes]=None)
at: aioquic.quic.connection.QuicConnection.__init__
self._cryptos: Dict[tls.Epoch, CryptoPair] = {}
self._loss = QuicPacketRecovery(
is_client_without_1rtt=self._is_client,
quic_logger=self._quic_logger,
send_probe=self._send_probe,
)
self._network_paths: List[QuicNetworkPath] = []
self._spaces: Dict[tls.Epoch, QuicPacketSpace] = {}
at: aioquic.quic.connection.QuicConnection._initialize
self._cryptos = {
tls.Epoch.INITIAL: CryptoPair(),
tls.Epoch.ZERO_RTT: CryptoPair(),
tls.Epoch.HANDSHAKE: CryptoPair(),
tls.Epoch.ONE_RTT: CryptoPair(),
}
self._spaces = {
tls.Epoch.INITIAL: QuicPacketSpace(),
tls.Epoch.HANDSHAKE: QuicPacketSpace(),
tls.Epoch.ONE_RTT: QuicPacketSpace(),
}
at: aioquic.quic.connection.QuicConnection.connect
self._network_paths = [QuicNetworkPath(addr, is_validated=True)]
at: aioquic.quic.connection.QuicConnection.receive_datagram
self._network_paths = [network_path]
at: aioquic.quic.connection.QuicNetworkPath
addr: NetworkAddress
bytes_received: int = 0
bytes_sent: int = 0
is_validated: bool = False
local_challenge: Optional[bytes] = None
remote_challenge: Optional[bytes] = None
===========unchanged ref 1===========
at: aioquic.quic.crypto.CryptoPair
teardown() -> None
at: aioquic.quic.recovery.QuicPacketRecovery
discard_space(space: QuicPacketSpace) -> None
===========changed ref 0===========
# module: aioquic.quic.connection
class QuicConnection:
def change_connection_id(self) -> None:
"""
Switch to the next available connection ID and retire
the previous one.
"""
if self._peer_cid_available:
# retire previous CID
+ self._logger.debug(
+ "Retiring %s (%d)", dump_cid(self._peer_cid), self._peer_cid_seq
+ )
self._retire_connection_ids.append(self._peer_cid_seq)
# assign new CID
connection_id = self._peer_cid_available.pop(0)
self._peer_cid_seq = connection_id.sequence_number
self._peer_cid = connection_id.cid
+ self._logger.debug(
- self._logger.info(
"Migrating to %s (%d)", dump_cid(self._peer_cid), self._peer_cid_seq
)
===========changed ref 1===========
# module: aioquic.quic.connection
class QuicConnection:
def receive_datagram(self, data: bytes, addr: NetworkAddress, now: float) -> None:
"""
Handle an incoming datagram.
:param data: The datagram which was received.
:param addr: The network address from which the datagram was received.
:param now: The current time.
"""
# stop handling packets when closing
if self._state in END_STATES:
return
data = cast(bytes, data)
if self._quic_logger is not None:
self._quic_logger.log_event(
category="transport",
event="datagram_received",
data={"byte_length": len(data), "count": 1},
)
buf = Buffer(data=data)
while not buf.eof():
start_off = buf.tell()
try:
header = pull_quic_header(buf, host_cid_length=len(self.host_cid))
except ValueError:
return
# check destination CID matches
destination_cid_seq: Optional[int] = None
for connection_id in self._host_cids:
if header.destination_cid == connection_id.cid:
destination_cid_seq = connection_id.sequence_number
break
if self._is_client and destination_cid_seq is None:
return
# check protocol version
if self._is_client and header.version == QuicProtocolVersion.NEGOTIATION:
# version negotiation
versions = []
while not buf.eof():
versions.append(buf.pull_uint32())
if self._quic_logger is not None:
self._quic_logger.log_event(
category="transport",
event="packet_received",
data={
"packet_type": "version_negotiation",
"header": {
"scid": dump_cid(header.source_cid),
"dcid": dump_cid(header.destination_cid),</s>
===========changed ref 2===========
# module: aioquic.quic.connection
class QuicConnection:
def receive_datagram(self, data: bytes, addr: NetworkAddress, now: float) -> None:
# offset: 1
<s> "scid": dump_cid(header.source_cid),
"dcid": dump_cid(header.destination_cid),
},
"frames": [],
},
)
common = set(self._configuration.supported_versions).intersection(
versions
)
if not common:
self._logger.error("Could not find a common protocol version")
self._close_event = events.ConnectionTerminated(
error_code=QuicErrorCode.INTERNAL_ERROR,
frame_type=None,
reason_phrase="Could not find a common protocol version",
)
self._close_end()
return
self._version = QuicProtocolVersion(max(common))
self._logger.info("Retrying with %s", self._version)
self._connect(now=now)
return
elif (
header.version is not None
and header.version not in self._configuration.supported_versions
):
# unsupported version
return
if self._is_client and header.packet_type == PACKET_TYPE_RETRY:
# stateless retry
if (
header.destination_cid == self.host_cid
and header.original_destination_cid == self._peer_cid
and not self._stateless_retry_count
):
if self._quic_logger is not None:
self._quic_logger.log_event(
category="transport",
event="packet_received",
data={
"packet_type": "retry",
"header": {
"scid": dump_cid(header.source_cid),
"dcid": dump_cid(header.destination_cid),
},
"frames": [],
},
)
self</s>
|
aioquic.quic.connection/QuicConnection._handle_path_response_frame
|
Modified
|
aiortc~aioquic
|
d65f3a5782c3f85c17dbcff139c619b94d9d1d71
|
[logging] reduce level of CID / network path messages
|
<17>:<add> self._logger.debug(
<del> self._logger.info(
|
# module: aioquic.quic.connection
class QuicConnection:
def _handle_path_response_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
<0> """
<1> Handle a PATH_RESPONSE frame.
<2> """
<3> data = buf.pull_bytes(8)
<4>
<5> # log frame
<6> if self._quic_logger is not None:
<7> context.quic_logger_frames.append(
<8> self._quic_logger.encode_path_response_frame(data=data)
<9> )
<10>
<11> if data != context.network_path.local_challenge:
<12> raise QuicConnectionError(
<13> error_code=QuicErrorCode.PROTOCOL_VIOLATION,
<14> frame_type=frame_type,
<15> reason_phrase="Response does not match challenge",
<16> )
<17> self._logger.info(
<18> "Network path %s validated by challenge", context.network_path.addr
<19> )
<20> context.network_path.is_validated = True
<21>
|
===========unchanged ref 0===========
at: aioquic._buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic._buffer.Buffer
pull_bytes(length: int) -> bytes
at: aioquic.quic.connection
QuicConnectionError(error_code: int, frame_type: int, reason_phrase: str)
QuicReceiveContext(epoch: tls.Epoch, host_cid: bytes, network_path: QuicNetworkPath, quic_logger_frames: Optional[List[Any]], time: float)
at: aioquic.quic.connection.QuicConnection.__init__
self._quic_logger = configuration.quic_logger
self._logger = QuicConnectionAdapter(
logger, {"host_cid": dump_cid(self.host_cid)}
)
at: aioquic.quic.connection.QuicConnection._handle_path_challenge_frame
data = buf.pull_bytes(8)
at: aioquic.quic.connection.QuicNetworkPath
local_challenge: Optional[bytes] = None
remote_challenge: Optional[bytes] = None
at: aioquic.quic.connection.QuicReceiveContext
epoch: tls.Epoch
host_cid: bytes
network_path: QuicNetworkPath
quic_logger_frames: Optional[List[Any]]
time: float
at: aioquic.quic.logger.QuicLogger
encode_path_response_frame(data: bytes) -> Dict
at: aioquic.quic.packet
QuicErrorCode(x: Union[str, bytes, bytearray], base: int)
QuicErrorCode(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
at: logging.LoggerAdapter
debug(msg: Any, *args: Any, exc_info: _ExcInfoType=..., stack_info: bool=..., extra: Optional[Dict[str, Any]]=..., **kwargs: Any) -> None
===========changed ref 0===========
# module: aioquic.quic.connection
class QuicConnection:
def _find_network_path(self, addr: NetworkAddress) -> QuicNetworkPath:
# check existing network paths
for idx, network_path in enumerate(self._network_paths):
if network_path.addr == addr:
return network_path
# new network path
network_path = QuicNetworkPath(addr)
+ self._logger.debug("Network path %s discovered", network_path.addr)
- self._logger.info("Network path %s discovered", network_path.addr)
return network_path
===========changed ref 1===========
# module: aioquic.quic.connection
class QuicConnection:
def change_connection_id(self) -> None:
"""
Switch to the next available connection ID and retire
the previous one.
"""
if self._peer_cid_available:
# retire previous CID
+ self._logger.debug(
+ "Retiring %s (%d)", dump_cid(self._peer_cid), self._peer_cid_seq
+ )
self._retire_connection_ids.append(self._peer_cid_seq)
# assign new CID
connection_id = self._peer_cid_available.pop(0)
self._peer_cid_seq = connection_id.sequence_number
self._peer_cid = connection_id.cid
+ self._logger.debug(
- self._logger.info(
"Migrating to %s (%d)", dump_cid(self._peer_cid), self._peer_cid_seq
)
===========changed ref 2===========
# module: aioquic.quic.connection
class QuicConnection:
def receive_datagram(self, data: bytes, addr: NetworkAddress, now: float) -> None:
"""
Handle an incoming datagram.
:param data: The datagram which was received.
:param addr: The network address from which the datagram was received.
:param now: The current time.
"""
# stop handling packets when closing
if self._state in END_STATES:
return
data = cast(bytes, data)
if self._quic_logger is not None:
self._quic_logger.log_event(
category="transport",
event="datagram_received",
data={"byte_length": len(data), "count": 1},
)
buf = Buffer(data=data)
while not buf.eof():
start_off = buf.tell()
try:
header = pull_quic_header(buf, host_cid_length=len(self.host_cid))
except ValueError:
return
# check destination CID matches
destination_cid_seq: Optional[int] = None
for connection_id in self._host_cids:
if header.destination_cid == connection_id.cid:
destination_cid_seq = connection_id.sequence_number
break
if self._is_client and destination_cid_seq is None:
return
# check protocol version
if self._is_client and header.version == QuicProtocolVersion.NEGOTIATION:
# version negotiation
versions = []
while not buf.eof():
versions.append(buf.pull_uint32())
if self._quic_logger is not None:
self._quic_logger.log_event(
category="transport",
event="packet_received",
data={
"packet_type": "version_negotiation",
"header": {
"scid": dump_cid(header.source_cid),
"dcid": dump_cid(header.destination_cid),</s>
===========changed ref 3===========
# module: aioquic.quic.connection
class QuicConnection:
def receive_datagram(self, data: bytes, addr: NetworkAddress, now: float) -> None:
# offset: 1
<s> "scid": dump_cid(header.source_cid),
"dcid": dump_cid(header.destination_cid),
},
"frames": [],
},
)
common = set(self._configuration.supported_versions).intersection(
versions
)
if not common:
self._logger.error("Could not find a common protocol version")
self._close_event = events.ConnectionTerminated(
error_code=QuicErrorCode.INTERNAL_ERROR,
frame_type=None,
reason_phrase="Could not find a common protocol version",
)
self._close_end()
return
self._version = QuicProtocolVersion(max(common))
self._logger.info("Retrying with %s", self._version)
self._connect(now=now)
return
elif (
header.version is not None
and header.version not in self._configuration.supported_versions
):
# unsupported version
return
if self._is_client and header.packet_type == PACKET_TYPE_RETRY:
# stateless retry
if (
header.destination_cid == self.host_cid
and header.original_destination_cid == self._peer_cid
and not self._stateless_retry_count
):
if self._quic_logger is not None:
self._quic_logger.log_event(
category="transport",
event="packet_received",
data={
"packet_type": "retry",
"header": {
"scid": dump_cid(header.source_cid),
"dcid": dump_cid(header.destination_cid),
},
"frames": [],
},
)
self</s>
|
aioquic.quic.connection/QuicConnection._handle_retire_connection_id_frame
|
Modified
|
aiortc~aioquic
|
d65f3a5782c3f85c17dbcff139c619b94d9d1d71
|
[logging] reduce level of CID / network path messages
|
<20>:<add> self._logger.debug(
<add> "Peer retiring %s (%d)",
<add> dump_cid(connection_id.cid),
<add> connection_id.sequence_number,
<add> )
|
# module: aioquic.quic.connection
class QuicConnection:
def _handle_retire_connection_id_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
<0> """
<1> Handle a RETIRE_CONNECTION_ID frame.
<2> """
<3> sequence_number = buf.pull_uint_var()
<4>
<5> # log frame
<6> if self._quic_logger is not None:
<7> context.quic_logger_frames.append(
<8> self._quic_logger.encode_retire_connection_id_frame(sequence_number)
<9> )
<10>
<11> # find the connection ID by sequence number
<12> for index, connection_id in enumerate(self._host_cids):
<13> if connection_id.sequence_number == sequence_number:
<14> if connection_id.cid == context.host_cid:
<15> raise QuicConnectionError(
<16> error_code=QuicErrorCode.PROTOCOL_VIOLATION,
<17> frame_type=frame_type,
<18> reason_phrase="Cannot retire current connection ID",
<19> )
<20> del self._host_cids[index]
<21> self._events.append(
<22> events.ConnectionIdRetired(connection_id=connection_id.cid)
<23> )
<24> break
<25>
<26> # issue a new connection ID
<27> self._replenish_connection_ids()
<28>
|
===========unchanged ref 0===========
at: aioquic._buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic._buffer.Buffer
pull_uint_var() -> int
at: aioquic.quic.connection
dump_cid(cid: bytes) -> str
QuicConnectionError(error_code: int, frame_type: int, reason_phrase: str)
QuicReceiveContext(epoch: tls.Epoch, host_cid: bytes, network_path: QuicNetworkPath, quic_logger_frames: Optional[List[Any]], time: float)
at: aioquic.quic.connection.QuicConnection.__init__
self._quic_logger = configuration.quic_logger
self._events: Deque[events.QuicEvent] = deque()
self._host_cids = [
QuicConnectionId(
cid=os.urandom(8),
sequence_number=0,
stateless_reset_token=os.urandom(16),
was_sent=True,
)
]
self._logger = QuicConnectionAdapter(
logger, {"host_cid": dump_cid(self.host_cid)}
)
at: aioquic.quic.connection.QuicConnection._handle_reset_stream_frame
stream_id = buf.pull_uint_var()
at: aioquic.quic.connection.QuicConnectionId
cid: bytes
sequence_number: int
at: aioquic.quic.connection.QuicReceiveContext
host_cid: bytes
quic_logger_frames: Optional[List[Any]]
at: aioquic.quic.events
StreamReset(stream_id: int)
at: aioquic.quic.events.StreamReset
stream_id: int
at: aioquic.quic.logger.QuicLogger
encode_retire_connection_id_frame(sequence_number: int) -> Dict
===========unchanged ref 1===========
at: aioquic.quic.packet
QuicErrorCode(x: Union[str, bytes, bytearray], base: int)
QuicErrorCode(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
at: collections.deque
append(x: _T) -> None
at: logging.LoggerAdapter
debug(msg: Any, *args: Any, exc_info: _ExcInfoType=..., stack_info: bool=..., extra: Optional[Dict[str, Any]]=..., **kwargs: Any) -> None
===========changed ref 0===========
# module: aioquic.quic.connection
class QuicConnection:
def _handle_path_response_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a PATH_RESPONSE frame.
"""
data = buf.pull_bytes(8)
# log frame
if self._quic_logger is not None:
context.quic_logger_frames.append(
self._quic_logger.encode_path_response_frame(data=data)
)
if data != context.network_path.local_challenge:
raise QuicConnectionError(
error_code=QuicErrorCode.PROTOCOL_VIOLATION,
frame_type=frame_type,
reason_phrase="Response does not match challenge",
)
+ self._logger.debug(
- self._logger.info(
"Network path %s validated by challenge", context.network_path.addr
)
context.network_path.is_validated = True
===========changed ref 1===========
# module: aioquic.quic.connection
class QuicConnection:
def _find_network_path(self, addr: NetworkAddress) -> QuicNetworkPath:
# check existing network paths
for idx, network_path in enumerate(self._network_paths):
if network_path.addr == addr:
return network_path
# new network path
network_path = QuicNetworkPath(addr)
+ self._logger.debug("Network path %s discovered", network_path.addr)
- self._logger.info("Network path %s discovered", network_path.addr)
return network_path
===========changed ref 2===========
# module: aioquic.quic.connection
class QuicConnection:
def change_connection_id(self) -> None:
"""
Switch to the next available connection ID and retire
the previous one.
"""
if self._peer_cid_available:
# retire previous CID
+ self._logger.debug(
+ "Retiring %s (%d)", dump_cid(self._peer_cid), self._peer_cid_seq
+ )
self._retire_connection_ids.append(self._peer_cid_seq)
# assign new CID
connection_id = self._peer_cid_available.pop(0)
self._peer_cid_seq = connection_id.sequence_number
self._peer_cid = connection_id.cid
+ self._logger.debug(
- self._logger.info(
"Migrating to %s (%d)", dump_cid(self._peer_cid), self._peer_cid_seq
)
===========changed ref 3===========
# module: aioquic.quic.connection
class QuicConnection:
def receive_datagram(self, data: bytes, addr: NetworkAddress, now: float) -> None:
"""
Handle an incoming datagram.
:param data: The datagram which was received.
:param addr: The network address from which the datagram was received.
:param now: The current time.
"""
# stop handling packets when closing
if self._state in END_STATES:
return
data = cast(bytes, data)
if self._quic_logger is not None:
self._quic_logger.log_event(
category="transport",
event="datagram_received",
data={"byte_length": len(data), "count": 1},
)
buf = Buffer(data=data)
while not buf.eof():
start_off = buf.tell()
try:
header = pull_quic_header(buf, host_cid_length=len(self.host_cid))
except ValueError:
return
# check destination CID matches
destination_cid_seq: Optional[int] = None
for connection_id in self._host_cids:
if header.destination_cid == connection_id.cid:
destination_cid_seq = connection_id.sequence_number
break
if self._is_client and destination_cid_seq is None:
return
# check protocol version
if self._is_client and header.version == QuicProtocolVersion.NEGOTIATION:
# version negotiation
versions = []
while not buf.eof():
versions.append(buf.pull_uint32())
if self._quic_logger is not None:
self._quic_logger.log_event(
category="transport",
event="packet_received",
data={
"packet_type": "version_negotiation",
"header": {
"scid": dump_cid(header.source_cid),
"dcid": dump_cid(header.destination_cid),</s>
|
aioquic.quic.connection/QuicConnection._write_application
|
Modified
|
aiortc~aioquic
|
d65f3a5782c3f85c17dbcff139c619b94d9d1d71
|
[logging] reduce level of CID / network path messages
|
<28>:<add> self._logger.debug(
<del> self._logger.info(
|
# module: aioquic.quic.connection
class QuicConnection:
def _write_application(
self, builder: QuicPacketBuilder, network_path: QuicNetworkPath, now: float
) -> None:
<0> crypto_stream: Optional[QuicStream] = None
<1> if self._cryptos[tls.Epoch.ONE_RTT].send.is_valid():
<2> crypto = self._cryptos[tls.Epoch.ONE_RTT]
<3> crypto_stream = self._crypto_streams[tls.Epoch.ONE_RTT]
<4> packet_type = PACKET_TYPE_ONE_RTT
<5> elif self._cryptos[tls.Epoch.ZERO_RTT].send.is_valid():
<6> crypto = self._cryptos[tls.Epoch.ZERO_RTT]
<7> packet_type = PACKET_TYPE_ZERO_RTT
<8> else:
<9> return
<10> space = self._spaces[tls.Epoch.ONE_RTT]
<11>
<12> buf = builder.buffer
<13>
<14> while True:
<15> # write header
<16> builder.start_packet(packet_type, crypto)
<17>
<18> if self._handshake_complete:
<19> # ACK
<20> if space.ack_at is not None and space.ack_at <= now:
<21> self._write_ack_frame(builder=builder, space=space)
<22>
<23> # PATH CHALLENGE
<24> if (
<25> not network_path.is_validated
<26> and network_path.local_challenge is None
<27> ):
<28> self._logger.info(
<29> "Network path %s sending challenge", network_path.addr
<30> )
<31> network_path.local_challenge = os.urandom(8)
<32> builder.start_frame(QuicFrameType.PATH_CHALLENGE)
<33> buf.push_bytes(network_path.local_challenge)
<34>
<35> # log frame
<36> if self._quic_logger is not None:
<37> builder.quic_logger_frames.append(
<38> self._quic_logger.encode</s>
|
===========below chunk 0===========
# module: aioquic.quic.connection
class QuicConnection:
def _write_application(
self, builder: QuicPacketBuilder, network_path: QuicNetworkPath, now: float
) -> None:
# offset: 1
data=network_path.local_challenge
)
)
# PATH RESPONSE
if network_path.remote_challenge is not None:
challenge = network_path.remote_challenge
builder.start_frame(QuicFrameType.PATH_RESPONSE)
buf.push_bytes(challenge)
network_path.remote_challenge = None
# log frame
if self._quic_logger is not None:
builder.quic_logger_frames.append(
self._quic_logger.encode_path_response_frame(data=challenge)
)
# NEW_CONNECTION_ID
for connection_id in self._host_cids:
if not connection_id.was_sent:
self._write_new_connection_id_frame(
builder=builder, connection_id=connection_id
)
# RETIRE_CONNECTION_ID
while self._retire_connection_ids:
sequence_number = self._retire_connection_ids.pop(0)
self._write_retire_connection_id_frame(
builder=builder, sequence_number=sequence_number
)
# STREAMS_BLOCKED
if self._streams_blocked_pending:
if self._streams_blocked_bidi:
self._write_streams_blocked_frame(
builder=builder,
frame_type=QuicFrameType.STREAMS_BLOCKED_BIDI,
limit=self._remote_max_streams_bidi,
)
if self._streams_blocked_uni:
self._write_streams_blocked_frame(
builder=builder,
frame_type=QuicFrameType.STREAMS_BLOCKED_UNI,
limit=self._remote_max_streams_uni,
)
self._streams_blocked_pending = False
# connection-</s>
===========below chunk 1===========
# module: aioquic.quic.connection
class QuicConnection:
def _write_application(
self, builder: QuicPacketBuilder, network_path: QuicNetworkPath, now: float
) -> None:
# offset: 2
<s>._remote_max_streams_uni,
)
self._streams_blocked_pending = False
# connection-level limits
self._write_connection_limits(builder=builder, space=space)
# stream-level limits
for stream in self._streams.values():
self._write_stream_limits(builder=builder, space=space, stream=stream)
# PING (user-request)
if self._ping_pending:
self._logger.info("Sending PING in packet %d", builder.packet_number)
self._write_ping_frame(builder, self._ping_pending)
self._ping_pending.clear()
# PING (probe)
if self._probe_pending:
self._logger.info(
"Sending PING (probe) in packet %d", builder.packet_number
)
self._write_ping_frame(builder)
self._probe_pending = False
# CRYPTO
if crypto_stream is not None and not crypto_stream.send_buffer_is_empty:
self._write_crypto_frame(
builder=builder, space=space, stream=crypto_stream
)
for stream in self._streams.values():
# STREAM
if not stream.is_blocked and not stream.send_buffer_is_empty:
self._remote_max_data_used += self._write_stream_frame(
builder=builder,
space=space,
stream=stream,
max_offset=min(
stream._send_highest
+ self._remote_max_data
- self._remote_max_data_used,
stream.max_stream_data_remote,
),
===========unchanged ref 0===========
at: aioquic._buffer.Buffer
push_bytes(value: bytes) -> None
at: aioquic.quic.connection
QuicNetworkPath(addr: NetworkAddress, bytes_received: int=0, bytes_sent: int=0, is_validated: bool=False, local_challenge: Optional[bytes]=None, remote_challenge: Optional[bytes]=None)
at: aioquic.quic.connection.QuicConnection
_write_ack_frame(builder: QuicPacketBuilder, space: QuicPacketSpace)
_write_connection_limits(builder: QuicPacketBuilder, space: QuicPacketSpace) -> None
_write_crypto_frame(builder: QuicPacketBuilder, space: QuicPacketSpace, stream: QuicStream) -> None
_write_new_connection_id_frame(builder: QuicPacketBuilder, connection_id: QuicConnectionId) -> None
_write_ping_frame(builder: QuicPacketBuilder, uids: List[int]=[])
_write_retire_connection_id_frame(builder: QuicPacketBuilder, sequence_number: int) -> None
_write_stream_frame(builder: QuicPacketBuilder, space: QuicPacketSpace, stream: QuicStream, max_offset: int) -> int
_write_stream_limits(builder: QuicPacketBuilder, space: QuicPacketSpace, stream: QuicStream) -> None
_write_streams_blocked_frame(builder: QuicPacketBuilder, frame_type: QuicFrameType, limit: int) -> None
at: aioquic.quic.connection.QuicConnection.__init__
self._quic_logger = configuration.quic_logger
self._cryptos: Dict[tls.Epoch, CryptoPair] = {}
self._crypto_streams: Dict[tls.Epoch, QuicStream] = {}
self._handshake_complete = False
===========unchanged ref 1===========
self._host_cids = [
QuicConnectionId(
cid=os.urandom(8),
sequence_number=0,
stateless_reset_token=os.urandom(16),
was_sent=True,
)
]
self._logger = QuicConnectionAdapter(
logger, {"host_cid": dump_cid(self.host_cid)}
)
self._remote_max_data_used = 0
self._remote_max_streams_bidi = 0
self._remote_max_streams_uni = 0
self._spaces: Dict[tls.Epoch, QuicPacketSpace] = {}
self._streams: Dict[int, QuicStream] = {}
self._streams_blocked_bidi: List[QuicStream] = []
self._streams_blocked_uni: List[QuicStream] = []
self._ping_pending: List[int] = []
self._probe_pending = False
self._retire_connection_ids: List[int] = []
self._streams_blocked_pending = False
at: aioquic.quic.connection.QuicConnection._create_stream
self._streams_blocked_pending = True
at: aioquic.quic.connection.QuicConnection._handle_crypto_frame
self._handshake_complete = True
at: aioquic.quic.connection.QuicConnection._handle_max_streams_bidi_frame
self._remote_max_streams_bidi = max_streams
at: aioquic.quic.connection.QuicConnection._handle_max_streams_uni_frame
self._remote_max_streams_uni = max_streams
at: aioquic.quic.connection.QuicConnection._initialize
self._cryptos = {
tls.Epoch.INITIAL: CryptoPair(),
tls.Epoch.ZERO_RTT: CryptoPair(),
tls.Epoch.HANDSHAKE: CryptoPair(),
tls.Epoch.ONE_RTT: CryptoPair(),
}
|
aioquic.quic.logger/QuicLogger.__init__
|
Modified
|
aiortc~aioquic
|
adffe76168a7543542aab796755fd7faad422b72
|
[logging] use the original destination CID as the identifier
|
<0>:<add> self._odcid: bytes = b""
|
# module: aioquic.quic.logger
class QuicLogger:
def __init__(self) -> None:
<0> self._events: Deque[Tuple[float, str, str, Dict[str, Any]]] = deque()
<1> self._vantage_point = {"name": "aioquic", "type": "unknown"}
<2>
|
===========unchanged ref 0===========
at: aioquic.quic.logger.QuicLogger.start_trace
self._odcid = odcid
at: collections
deque(iterable: Iterable[_T]=..., maxlen: Optional[int]=...)
at: typing
Tuple = _TupleType(tuple, -1, inst=False, name='Tuple')
Deque = _alias(collections.deque, 1, name='Deque')
Dict = _alias(dict, 2, inst=False, name='Dict')
|
aioquic.quic.logger/QuicLogger.start_trace
|
Modified
|
aiortc~aioquic
|
adffe76168a7543542aab796755fd7faad422b72
|
[logging] use the original destination CID as the identifier
|
<0>:<add> self._odcid = odcid
|
# module: aioquic.quic.logger
class QuicLogger:
+ def start_trace(self, is_client: bool, odcid: bytes) -> None:
- def start_trace(self, is_client: bool) -> None:
<0> self._vantage_point["type"] = "client" if is_client else "server"
<1>
|
===========changed ref 0===========
# module: aioquic.quic.logger
class QuicLogger:
def __init__(self) -> None:
+ self._odcid: bytes = b""
self._events: Deque[Tuple[float, str, str, Dict[str, Any]]] = deque()
self._vantage_point = {"name": "aioquic", "type": "unknown"}
|
aioquic.quic.logger/QuicLogger.to_dict
|
Modified
|
aiortc~aioquic
|
adffe76168a7543542aab796755fd7faad422b72
|
[logging] use the original destination CID as the identifier
|
<7>:<add> "common_fields": {
<add> "ODCID": hexdump(self._odcid),
<add> "reference_time": "%d" % (reference_time * 1000),
<del> "common_fields": {"reference_time": "%d" % (reference_time * 1000)},
<8>:<add> },
|
# module: aioquic.quic.logger
class QuicLogger:
def to_dict(self) -> Dict[str, Any]:
<0> """
<1> Return the trace as a dictionary which can be written as JSON.
<2> """
<3> traces = []
<4> if self._events:
<5> reference_time = self._events[0][0]
<6> trace = {
<7> "common_fields": {"reference_time": "%d" % (reference_time * 1000)},
<8> "event_fields": ["relative_time", "category", "event_type", "data"],
<9> "events": list(
<10> map(
<11> lambda event: (
<12> "%d" % ((event[0] - reference_time) * 1000),
<13> event[1],
<14> event[2],
<15> event[3],
<16> ),
<17> self._events,
<18> )
<19> ),
<20> "vantage_point": self._vantage_point,
<21> }
<22> traces.append(trace)
<23>
<24> return {"qlog_version": "draft-01", "traces": traces}
<25>
|
===========unchanged ref 0===========
at: aioquic.quic.logger
hexdump(data: bytes) -> str
at: aioquic.quic.logger.QuicLogger.__init__
self._odcid: bytes = b""
self._events: Deque[Tuple[float, str, str, Dict[str, Any]]] = deque()
self._vantage_point = {"name": "aioquic", "type": "unknown"}
at: aioquic.quic.logger.QuicLogger.start_trace
self._odcid = odcid
at: typing
Dict = _alias(dict, 2, inst=False, name='Dict')
===========changed ref 0===========
# module: aioquic.quic.logger
class QuicLogger:
+ def start_trace(self, is_client: bool, odcid: bytes) -> None:
- def start_trace(self, is_client: bool) -> None:
+ self._odcid = odcid
self._vantage_point["type"] = "client" if is_client else "server"
===========changed ref 1===========
# module: aioquic.quic.logger
class QuicLogger:
def __init__(self) -> None:
+ self._odcid: bytes = b""
self._events: Deque[Tuple[float, str, str, Dict[str, Any]]] = deque()
self._vantage_point = {"name": "aioquic", "type": "unknown"}
|
aioquic.quic.connection/QuicConnectionAdapter.process
|
Modified
|
aiortc~aioquic
|
adffe76168a7543542aab796755fd7faad422b72
|
[logging] use the original destination CID as the identifier
|
<0>:<add> return "[%s] %s" % (self.extra["id"], msg), kwargs
<del> return "[%s] %s" % (self.extra["host_cid"], msg), kwargs
|
# module: aioquic.quic.connection
class QuicConnectionAdapter(logging.LoggerAdapter):
def process(self, msg: str, kwargs: Any) -> Tuple[str, Any]:
<0> return "[%s] %s" % (self.extra["host_cid"], msg), kwargs
<1>
|
===========unchanged ref 0===========
at: logging.LoggerAdapter
extra: Mapping[str, Any]
process(self, msg: Any, kwargs: MutableMapping[str, Any]) -> Tuple[Any, MutableMapping[str, Any]]
__class_getitem__ = classmethod(GenericAlias)
at: typing
Tuple = _TupleType(tuple, -1, inst=False, name='Tuple')
===========changed ref 0===========
# module: aioquic.quic.logger
class QuicLogger:
+ def start_trace(self, is_client: bool, odcid: bytes) -> None:
- def start_trace(self, is_client: bool) -> None:
+ self._odcid = odcid
self._vantage_point["type"] = "client" if is_client else "server"
===========changed ref 1===========
# module: aioquic.quic.logger
class QuicLogger:
def __init__(self) -> None:
+ self._odcid: bytes = b""
self._events: Deque[Tuple[float, str, str, Dict[str, Any]]] = deque()
self._vantage_point = {"name": "aioquic", "type": "unknown"}
===========changed ref 2===========
# module: aioquic.quic.logger
class QuicLogger:
def to_dict(self) -> Dict[str, Any]:
"""
Return the trace as a dictionary which can be written as JSON.
"""
traces = []
if self._events:
reference_time = self._events[0][0]
trace = {
+ "common_fields": {
+ "ODCID": hexdump(self._odcid),
+ "reference_time": "%d" % (reference_time * 1000),
- "common_fields": {"reference_time": "%d" % (reference_time * 1000)},
+ },
"event_fields": ["relative_time", "category", "event_type", "data"],
"events": list(
map(
lambda event: (
"%d" % ((event[0] - reference_time) * 1000),
event[1],
event[2],
event[3],
),
self._events,
)
),
"vantage_point": self._vantage_point,
}
traces.append(trace)
return {"qlog_version": "draft-01", "traces": traces}
|
aioquic.asyncio.server/QuicServer.datagram_received
|
Modified
|
aiortc~aioquic
|
adffe76168a7543542aab796755fd7faad422b72
|
[logging] use the original destination CID as the identifier
|
# module: aioquic.asyncio.server
class QuicServer(asyncio.DatagramProtocol):
def datagram_received(self, data: Union[bytes, Text], addr: NetworkAddress) -> None:
<0> data = cast(bytes, data)
<1> buf = Buffer(data=data)
<2> header = pull_quic_header(buf, host_cid_length=8)
<3>
<4> # version negotiation
<5> if (
<6> header.version is not None
<7> and header.version not in self._configuration.supported_versions
<8> ):
<9> self._transport.sendto(
<10> encode_quic_version_negotiation(
<11> source_cid=header.destination_cid,
<12> destination_cid=header.source_cid,
<13> supported_versions=self._configuration.supported_versions,
<14> ),
<15> addr,
<16> )
<17> return
<18>
<19> protocol = self._protocols.get(header.destination_cid, None)
<20> original_connection_id: Optional[bytes] = None
<21> if protocol is None and header.packet_type == PACKET_TYPE_INITIAL:
<22> # stateless retry
<23> if self._retry is not None:
<24> if not header.token:
<25> # create a retry token
<26> self._transport.sendto(
<27> encode_quic_retry(
<28> version=header.version,
<29> source_cid=os.urandom(8),
<30> destination_cid=header.source_cid,
<31> original_destination_cid=header.destination_cid,
<32> retry_token=self._retry.create_token(
<33> addr, header.destination_cid
<34> ),
<35> ),
<36> addr,
<37> )
<38> return
<39> else:
<40> # validate retry token
<41> try:
<42> original_connection_id = self._retry.validate_token(
<43> addr, header.token
<44> )
<45> except ValueError:
<46> return
<47>
<48> # create new connection
<49> connection = QuicConnection(
<50> configuration=</s>
|
===========below chunk 0===========
# module: aioquic.asyncio.server
class QuicServer(asyncio.DatagramProtocol):
def datagram_received(self, data: Union[bytes, Text], addr: NetworkAddress) -> None:
# offset: 1
original_connection_id=original_connection_id,
session_ticket_fetcher=self._session_ticket_fetcher,
session_ticket_handler=self._session_ticket_handler,
)
protocol = self._create_protocol(
connection, stream_handler=self._stream_handler
)
protocol.connection_made(self._transport)
# register callbacks
protocol._connection_id_issued_handler = partial(
self._connection_id_issued, protocol=protocol
)
protocol._connection_id_retired_handler = partial(
self._connection_id_retired, protocol=protocol
)
protocol._connection_terminated_handler = partial(
self._connection_terminated, protocol=protocol
)
self._protocols[header.destination_cid] = protocol
self._protocols[connection.host_cid] = protocol
if protocol is not None:
protocol.datagram_received(data, addr)
===========unchanged ref 0===========
at: aioquic._buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic.asyncio.server.QuicServer
_connection_id_issued(cid: bytes, protocol: QuicConnectionProtocol)
_connection_id_retired(cid: bytes, protocol: QuicConnectionProtocol) -> None
_connection_terminated(protocol: QuicConnectionProtocol)
at: aioquic.asyncio.server.QuicServer.__init__
self._configuration = configuration
self._create_protocol = create_protocol
self._protocols: Dict[bytes, QuicConnectionProtocol] = {}
self._session_ticket_fetcher = session_ticket_fetcher
self._session_ticket_handler = session_ticket_handler
self._transport: Optional[asyncio.DatagramTransport] = None
self._stream_handler = stream_handler
self._retry = QuicRetryTokenHandler()
self._retry = None
at: aioquic.asyncio.server.QuicServer.connection_made
self._transport = cast(asyncio.DatagramTransport, transport)
at: aioquic.quic.configuration.QuicConfiguration
alpn_protocols: Optional[List[str]] = None
certificate: Any = None
idle_timeout: float = 60.0
is_client: bool = True
private_key: Any = None
quic_logger: Optional[QuicLogger] = None
secrets_log_file: TextIO = None
server_name: Optional[str] = None
session_ticket: Optional[SessionTicket] = None
supported_versions: List[int] = field(
default_factory=lambda: [QuicProtocolVersion.DRAFT_22]
)
at: aioquic.quic.connection
NetworkAddress = Any
===========unchanged ref 1===========
QuicConnection(*, configuration: QuicConfiguration, logger_connection_id: Optional[bytes]=None, original_connection_id: Optional[bytes]=None, session_ticket_fetcher: Optional[tls.SessionTicketFetcher]=None, session_ticket_handler: Optional[tls.SessionTicketHandler]=None)
at: aioquic.quic.connection.QuicConnection.__init__
self.host_cid = self._host_cids[0].cid
at: aioquic.quic.connection.QuicConnection.receive_datagram
self.host_cid = context.host_cid
at: aioquic.quic.packet
PACKET_TYPE_INITIAL = PACKET_LONG_HEADER | PACKET_FIXED_BIT | 0x00
pull_quic_header(buf: Buffer, host_cid_length: Optional[int]=None) -> QuicHeader
encode_quic_retry(version: int, source_cid: bytes, destination_cid: bytes, original_destination_cid: bytes, retry_token: bytes) -> bytes
encode_quic_version_negotiation(source_cid: bytes, destination_cid: bytes, supported_versions: List[int]) -> bytes
at: aioquic.quic.packet.QuicHeader
is_long_header: bool
version: Optional[int]
packet_type: int
destination_cid: bytes
source_cid: bytes
original_destination_cid: bytes = b""
token: bytes = b""
rest_length: int = 0
at: aioquic.quic.retry.QuicRetryTokenHandler
create_token(addr: NetworkAddress, destination_cid: bytes) -> bytes
validate_token(addr: NetworkAddress, token: bytes) -> bytes
at: asyncio.protocols.DatagramProtocol
__slots__ = ()
datagram_received(self, data: bytes, addr: Tuple[str, int]) -> None
at: asyncio.transports.DatagramTransport
__slots__ = ()
===========unchanged ref 2===========
sendto(data: Any, addr: Optional[_Address]=...) -> None
at: functools
partial(func: Callable[..., _T], *args: Any, **kwargs: Any)
partial(func, *args, **keywords, /) -> function with partial application()
at: os
urandom(size: int, /) -> bytes
at: typing
cast(typ: Type[_T], val: Any) -> _T
cast(typ: str, val: Any) -> Any
cast(typ: object, val: Any) -> Any
Text = str
at: typing.Mapping
get(key: _KT, default: Union[_VT_co, _T]) -> Union[_VT_co, _T]
get(key: _KT) -> Optional[_VT_co]
===========changed ref 0===========
# module: aioquic.quic.logger
class QuicLogger:
+ def start_trace(self, is_client: bool, odcid: bytes) -> None:
- def start_trace(self, is_client: bool) -> None:
+ self._odcid = odcid
self._vantage_point["type"] = "client" if is_client else "server"
===========changed ref 1===========
# module: aioquic.quic.connection
class QuicConnectionAdapter(logging.LoggerAdapter):
def process(self, msg: str, kwargs: Any) -> Tuple[str, Any]:
+ return "[%s] %s" % (self.extra["id"], msg), kwargs
- return "[%s] %s" % (self.extra["host_cid"], msg), kwargs
===========changed ref 2===========
# module: aioquic.quic.logger
class QuicLogger:
def __init__(self) -> None:
+ self._odcid: bytes = b""
self._events: Deque[Tuple[float, str, str, Dict[str, Any]]] = deque()
self._vantage_point = {"name": "aioquic", "type": "unknown"}
|
|
aioquic.asyncio.server/QuicServer.datagram_received
|
Modified
|
aiortc~aioquic
|
bf8dc0a359ab3fdf08c072e367f9a45a82706b79
|
[server] catch exception for invalid packets
|
<2>:<add>
<add> try:
<add> header = pull_quic_header(buf, host_cid_length=8)
<del> header = pull_quic_header(buf, host_cid_length=8)
<3>:<add> except ValueError:
<add> return
|
# module: aioquic.asyncio.server
class QuicServer(asyncio.DatagramProtocol):
def datagram_received(self, data: Union[bytes, Text], addr: NetworkAddress) -> None:
<0> data = cast(bytes, data)
<1> buf = Buffer(data=data)
<2> header = pull_quic_header(buf, host_cid_length=8)
<3>
<4> # version negotiation
<5> if (
<6> header.version is not None
<7> and header.version not in self._configuration.supported_versions
<8> ):
<9> self._transport.sendto(
<10> encode_quic_version_negotiation(
<11> source_cid=header.destination_cid,
<12> destination_cid=header.source_cid,
<13> supported_versions=self._configuration.supported_versions,
<14> ),
<15> addr,
<16> )
<17> return
<18>
<19> protocol = self._protocols.get(header.destination_cid, None)
<20> original_connection_id: Optional[bytes] = None
<21> if protocol is None and header.packet_type == PACKET_TYPE_INITIAL:
<22> # stateless retry
<23> if self._retry is not None:
<24> if not header.token:
<25> # create a retry token
<26> self._transport.sendto(
<27> encode_quic_retry(
<28> version=header.version,
<29> source_cid=os.urandom(8),
<30> destination_cid=header.source_cid,
<31> original_destination_cid=header.destination_cid,
<32> retry_token=self._retry.create_token(
<33> addr, header.destination_cid
<34> ),
<35> ),
<36> addr,
<37> )
<38> return
<39> else:
<40> # validate retry token
<41> try:
<42> original_connection_id = self._retry.validate_token(
<43> addr, header.token
<44> )
<45> except ValueError:
<46> return
<47>
<48> # create new connection
<49> connection = QuicConnection(
<50> configuration=</s>
|
===========below chunk 0===========
# module: aioquic.asyncio.server
class QuicServer(asyncio.DatagramProtocol):
def datagram_received(self, data: Union[bytes, Text], addr: NetworkAddress) -> None:
# offset: 1
logger_connection_id=original_connection_id or header.destination_cid,
original_connection_id=original_connection_id,
session_ticket_fetcher=self._session_ticket_fetcher,
session_ticket_handler=self._session_ticket_handler,
)
protocol = self._create_protocol(
connection, stream_handler=self._stream_handler
)
protocol.connection_made(self._transport)
# register callbacks
protocol._connection_id_issued_handler = partial(
self._connection_id_issued, protocol=protocol
)
protocol._connection_id_retired_handler = partial(
self._connection_id_retired, protocol=protocol
)
protocol._connection_terminated_handler = partial(
self._connection_terminated, protocol=protocol
)
self._protocols[header.destination_cid] = protocol
self._protocols[connection.host_cid] = protocol
if protocol is not None:
protocol.datagram_received(data, addr)
===========unchanged ref 0===========
at: aioquic._buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic.asyncio.server.QuicServer
_connection_id_issued(cid: bytes, protocol: QuicConnectionProtocol)
_connection_id_retired(cid: bytes, protocol: QuicConnectionProtocol) -> None
_connection_terminated(protocol: QuicConnectionProtocol)
at: aioquic.asyncio.server.QuicServer.__init__
self._configuration = configuration
self._create_protocol = create_protocol
self._protocols: Dict[bytes, QuicConnectionProtocol] = {}
self._session_ticket_fetcher = session_ticket_fetcher
self._session_ticket_handler = session_ticket_handler
self._transport: Optional[asyncio.DatagramTransport] = None
self._stream_handler = stream_handler
self._retry = QuicRetryTokenHandler()
self._retry = None
at: aioquic.asyncio.server.QuicServer.connection_made
self._transport = cast(asyncio.DatagramTransport, transport)
at: aioquic.quic.configuration.QuicConfiguration
alpn_protocols: Optional[List[str]] = None
certificate: Any = None
idle_timeout: float = 60.0
is_client: bool = True
private_key: Any = None
quic_logger: Optional[QuicLogger] = None
secrets_log_file: TextIO = None
server_name: Optional[str] = None
session_ticket: Optional[SessionTicket] = None
supported_versions: List[int] = field(
default_factory=lambda: [QuicProtocolVersion.DRAFT_22]
)
at: aioquic.quic.connection
NetworkAddress = Any
===========unchanged ref 1===========
QuicConnection(*, configuration: QuicConfiguration, logger_connection_id: Optional[bytes]=None, original_connection_id: Optional[bytes]=None, session_ticket_fetcher: Optional[tls.SessionTicketFetcher]=None, session_ticket_handler: Optional[tls.SessionTicketHandler]=None)
at: aioquic.quic.packet
PACKET_TYPE_INITIAL = PACKET_LONG_HEADER | PACKET_FIXED_BIT | 0x00
pull_quic_header(buf: Buffer, host_cid_length: Optional[int]=None) -> QuicHeader
encode_quic_retry(version: int, source_cid: bytes, destination_cid: bytes, original_destination_cid: bytes, retry_token: bytes) -> bytes
encode_quic_version_negotiation(source_cid: bytes, destination_cid: bytes, supported_versions: List[int]) -> bytes
at: aioquic.quic.packet.QuicHeader
is_long_header: bool
version: Optional[int]
packet_type: int
destination_cid: bytes
source_cid: bytes
original_destination_cid: bytes = b""
token: bytes = b""
rest_length: int = 0
at: aioquic.quic.retry.QuicRetryTokenHandler
create_token(addr: NetworkAddress, destination_cid: bytes) -> bytes
validate_token(addr: NetworkAddress, token: bytes) -> bytes
at: asyncio.protocols.DatagramProtocol
__slots__ = ()
datagram_received(self, data: bytes, addr: Tuple[str, int]) -> None
at: asyncio.transports.DatagramTransport
__slots__ = ()
sendto(data: Any, addr: Optional[_Address]=...) -> None
at: functools
partial(func: Callable[..., _T], *args: Any, **kwargs: Any)
partial(func, *args, **keywords, /) -> function with partial application()
===========unchanged ref 2===========
at: os
urandom(size: int, /) -> bytes
at: typing
cast(typ: Type[_T], val: Any) -> _T
cast(typ: str, val: Any) -> Any
cast(typ: object, val: Any) -> Any
Text = str
at: typing.Mapping
get(key: _KT, default: Union[_VT_co, _T]) -> Union[_VT_co, _T]
get(key: _KT) -> Optional[_VT_co]
|
aioquic.asyncio.server/QuicServer.datagram_received
|
Modified
|
aiortc~aioquic
|
e15ebc7356149e8bada06f935a2f5469e3d9165d
|
[server] only create connection if initial datagram is >= 1200 bytes
|
<25>:<add> if (
<add> protocol is None
<add> and len(data) >= 1200
<add> and header.packet_type == PACKET_TYPE_INITIAL
<del> if protocol is None and header.packet_type == PACKET_TYPE_INITIAL:
<26>:<add> ):
|
# module: aioquic.asyncio.server
class QuicServer(asyncio.DatagramProtocol):
def datagram_received(self, data: Union[bytes, Text], addr: NetworkAddress) -> None:
<0> data = cast(bytes, data)
<1> buf = Buffer(data=data)
<2>
<3> try:
<4> header = pull_quic_header(buf, host_cid_length=8)
<5> except ValueError:
<6> return
<7>
<8> # version negotiation
<9> if (
<10> header.version is not None
<11> and header.version not in self._configuration.supported_versions
<12> ):
<13> self._transport.sendto(
<14> encode_quic_version_negotiation(
<15> source_cid=header.destination_cid,
<16> destination_cid=header.source_cid,
<17> supported_versions=self._configuration.supported_versions,
<18> ),
<19> addr,
<20> )
<21> return
<22>
<23> protocol = self._protocols.get(header.destination_cid, None)
<24> original_connection_id: Optional[bytes] = None
<25> if protocol is None and header.packet_type == PACKET_TYPE_INITIAL:
<26> # stateless retry
<27> if self._retry is not None:
<28> if not header.token:
<29> # create a retry token
<30> self._transport.sendto(
<31> encode_quic_retry(
<32> version=header.version,
<33> source_cid=os.urandom(8),
<34> destination_cid=header.source_cid,
<35> original_destination_cid=header.destination_cid,
<36> retry_token=self._retry.create_token(
<37> addr, header.destination_cid
<38> ),
<39> ),
<40> addr,
<41> )
<42> return
<43> else:
<44> # validate retry token
<45> try:
<46> original_connection_id = self._retry.validate_token(
<47> addr, header.token
<48> )
<49> except ValueError:
<50> return
<51>
<52> #</s>
|
===========below chunk 0===========
# module: aioquic.asyncio.server
class QuicServer(asyncio.DatagramProtocol):
def datagram_received(self, data: Union[bytes, Text], addr: NetworkAddress) -> None:
# offset: 1
connection = QuicConnection(
configuration=self._configuration,
logger_connection_id=original_connection_id or header.destination_cid,
original_connection_id=original_connection_id,
session_ticket_fetcher=self._session_ticket_fetcher,
session_ticket_handler=self._session_ticket_handler,
)
protocol = self._create_protocol(
connection, stream_handler=self._stream_handler
)
protocol.connection_made(self._transport)
# register callbacks
protocol._connection_id_issued_handler = partial(
self._connection_id_issued, protocol=protocol
)
protocol._connection_id_retired_handler = partial(
self._connection_id_retired, protocol=protocol
)
protocol._connection_terminated_handler = partial(
self._connection_terminated, protocol=protocol
)
self._protocols[header.destination_cid] = protocol
self._protocols[connection.host_cid] = protocol
if protocol is not None:
protocol.datagram_received(data, addr)
===========unchanged ref 0===========
at: aioquic._buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic.asyncio.server.QuicServer
_connection_id_issued(cid: bytes, protocol: QuicConnectionProtocol)
_connection_id_retired(cid: bytes, protocol: QuicConnectionProtocol) -> None
_connection_terminated(protocol: QuicConnectionProtocol)
at: aioquic.asyncio.server.QuicServer.__init__
self._configuration = configuration
self._create_protocol = create_protocol
self._protocols: Dict[bytes, QuicConnectionProtocol] = {}
self._session_ticket_fetcher = session_ticket_fetcher
self._session_ticket_handler = session_ticket_handler
self._transport: Optional[asyncio.DatagramTransport] = None
self._stream_handler = stream_handler
self._retry = QuicRetryTokenHandler()
self._retry = None
at: aioquic.asyncio.server.QuicServer.connection_made
self._transport = cast(asyncio.DatagramTransport, transport)
at: aioquic.quic.configuration.QuicConfiguration
alpn_protocols: Optional[List[str]] = None
certificate: Any = None
idle_timeout: float = 60.0
is_client: bool = True
private_key: Any = None
quic_logger: Optional[QuicLogger] = None
secrets_log_file: TextIO = None
server_name: Optional[str] = None
session_ticket: Optional[SessionTicket] = None
supported_versions: List[int] = field(
default_factory=lambda: [QuicProtocolVersion.DRAFT_22]
)
at: aioquic.quic.connection
NetworkAddress = Any
===========unchanged ref 1===========
QuicConnection(*, configuration: QuicConfiguration, logger_connection_id: Optional[bytes]=None, original_connection_id: Optional[bytes]=None, session_ticket_fetcher: Optional[tls.SessionTicketFetcher]=None, session_ticket_handler: Optional[tls.SessionTicketHandler]=None)
at: aioquic.quic.packet
PACKET_TYPE_INITIAL = PACKET_LONG_HEADER | PACKET_FIXED_BIT | 0x00
pull_quic_header(buf: Buffer, host_cid_length: Optional[int]=None) -> QuicHeader
encode_quic_retry(version: int, source_cid: bytes, destination_cid: bytes, original_destination_cid: bytes, retry_token: bytes) -> bytes
encode_quic_version_negotiation(source_cid: bytes, destination_cid: bytes, supported_versions: List[int]) -> bytes
at: aioquic.quic.packet.QuicHeader
is_long_header: bool
version: Optional[int]
packet_type: int
destination_cid: bytes
source_cid: bytes
original_destination_cid: bytes = b""
token: bytes = b""
rest_length: int = 0
at: aioquic.quic.retry.QuicRetryTokenHandler
create_token(addr: NetworkAddress, destination_cid: bytes) -> bytes
validate_token(addr: NetworkAddress, token: bytes) -> bytes
at: asyncio.protocols.DatagramProtocol
__slots__ = ()
datagram_received(self, data: bytes, addr: Tuple[str, int]) -> None
at: asyncio.transports.DatagramTransport
__slots__ = ()
sendto(data: Any, addr: Optional[_Address]=...) -> None
at: functools
partial(func: Callable[..., _T], *args: Any, **kwargs: Any)
partial(func, *args, **keywords, /) -> function with partial application()
===========unchanged ref 2===========
at: os
urandom(size: int, /) -> bytes
at: typing
cast(typ: Type[_T], val: Any) -> _T
cast(typ: str, val: Any) -> Any
cast(typ: object, val: Any) -> Any
Text = str
at: typing.Mapping
get(key: _KT, default: Union[_VT_co, _T]) -> Union[_VT_co, _T]
get(key: _KT) -> Optional[_VT_co]
|
aioquic.quic.connection/QuicConnection._replenish_connection_ids
|
Modified
|
aiortc~aioquic
|
1519aec9ff7c8a04addfe641d7fd3b1c3160c99c
|
[config] make connection ID length configurable
|
<6>:<add> cid=os.urandom(self._configuration.connection_id_length),
<del> cid=os.urandom(8),
|
# module: aioquic.quic.connection
class QuicConnection:
def _replenish_connection_ids(self) -> None:
<0> """
<1> Generate new connection IDs.
<2> """
<3> while len(self._host_cids) < min(8, self._remote_active_connection_id_limit):
<4> self._host_cids.append(
<5> QuicConnectionId(
<6> cid=os.urandom(8),
<7> sequence_number=self._host_cid_seq,
<8> stateless_reset_token=os.urandom(16),
<9> )
<10> )
<11> self._host_cid_seq += 1
<12>
|
===========unchanged ref 0===========
at: aioquic.quic.configuration.QuicConfiguration
alpn_protocols: Optional[List[str]] = None
certificate: Any = None
connection_id_length: int = 8
idle_timeout: float = 60.0
is_client: bool = True
private_key: Any = None
quic_logger: Optional[QuicLogger] = None
secrets_log_file: TextIO = None
server_name: Optional[str] = None
session_ticket: Optional[SessionTicket] = None
supported_versions: List[int] = field(
default_factory=lambda: [QuicProtocolVersion.DRAFT_22]
)
at: aioquic.quic.connection
QuicConnectionId(cid: bytes, sequence_number: int, stateless_reset_token: bytes=b"", was_sent: bool=False)
at: aioquic.quic.connection.QuicConnection.__init__
self._configuration = configuration
self._host_cids = [
QuicConnectionId(
cid=os.urandom(configuration.connection_id_length),
sequence_number=0,
stateless_reset_token=os.urandom(16),
was_sent=True,
)
]
self._host_cid_seq = 1
self._remote_active_connection_id_limit = 0
at: aioquic.quic.connection.QuicConnection._parse_transport_parameters
self._remote_active_connection_id_limit = (
quic_transport_parameters.active_connection_id_limit
)
at: aioquic.quic.connection.QuicConnection._payload_received
is_ack_eliciting = False
is_ack_eliciting = True
is_probing = False
is_probing = None
is_probing = True
at: aioquic.quic.connection.QuicConnection._replenish_connection_ids
self._host_cid_seq += 1
===========unchanged ref 1===========
at: aioquic.quic.connection.QuicConnectionId
cid: bytes
sequence_number: int
stateless_reset_token: bytes = b""
was_sent: bool = False
at: os
urandom(size: int, /) -> bytes
===========changed ref 0===========
# module: aioquic.quic.configuration
@dataclass
class QuicConfiguration:
"""
A QUIC configuration.
"""
alpn_protocols: Optional[List[str]] = None
"""
A list of supported ALPN protocols.
"""
certificate: Any = None
"""
The server's TLS certificate.
See :func:`cryptography.x509.load_pem_x509_certificate`.
.. note:: This is only used by servers.
+ """
+
+ connection_id_length: int = 8
+ """
+ The length in bytes of local connection IDs.
"""
idle_timeout: float = 60.0
"""
The idle timeout in seconds.
The connection is terminated if nothing is received for the given duration.
"""
is_client: bool = True
"""
Whether this is the client side of the QUIC connection.
"""
private_key: Any = None
"""
The server's TLS private key.
See :func:`cryptography.hazmat.primitives.serialization.load_pem_private_key`.
.. note:: This is only used by servers.
"""
quic_logger: Optional[QuicLogger] = None
"""
The :class:`~aioquic.quic.logger.QuicLogger` instance to log events to.
"""
secrets_log_file: TextIO = None
"""
A file-like object in which to log traffic secrets.
This is useful to analyze traffic captures with Wireshark.
"""
server_name: Optional[str] = None
"""
The server name to send during the TLS handshake the Server Name Indication.
.. note:: This is only used by clients.
"""
session_ticket: Optional[SessionTicket] = None
"""
The TLS session ticket which should be used for session resumption.
"""
supported_versions: List[int] = field(
default_factory=lambda: [QuicProtocolVersion.DRAFT_22]
)
===========changed ref 1===========
# module: aioquic.quic.configuration
@dataclass
class QuicConfiguration:
# offset: 1
<s>_versions: List[int] = field(
default_factory=lambda: [QuicProtocolVersion.DRAFT_22]
)
===========changed ref 2===========
# module: aioquic.quic.connection
class QuicConnection:
def __init__(
self,
*,
configuration: QuicConfiguration,
logger_connection_id: Optional[bytes] = None,
original_connection_id: Optional[bytes] = None,
session_ticket_fetcher: Optional[tls.SessionTicketFetcher] = None,
session_ticket_handler: Optional[tls.SessionTicketHandler] = None,
) -> None:
if configuration.is_client:
assert (
original_connection_id is None
), "Cannot set original_connection_id for a client"
else:
assert (
configuration.certificate is not None
), "SSL certificate is required for a server"
assert (
configuration.private_key is not None
), "SSL private key is required for a server"
# configuration
self._configuration = configuration
self._is_client = configuration.is_client
self._ack_delay = K_GRANULARITY
self._close_at: Optional[float] = None
self._close_event: Optional[events.ConnectionTerminated] = None
self._connect_called = False
self._cryptos: Dict[tls.Epoch, CryptoPair] = {}
self._crypto_buffers: Dict[tls.Epoch, Buffer] = {}
self._crypto_streams: Dict[tls.Epoch, QuicStream] = {}
self._events: Deque[events.QuicEvent] = deque()
self._handshake_complete = False
self._handshake_confirmed = False
self._host_cids = [
QuicConnectionId(
+ cid=os.urandom(configuration.connection_id_length),
- cid=os.urandom(8),
sequence_number=0,
stateless_reset_token=os.urandom(16),
was_sent=True,
)
]
self.host_cid = self._host_cids[0].cid
self._host_cid_seq = 1
self._local_ack_delay_exponent = 3</s>
|
aioquic.asyncio.server/QuicServer.datagram_received
|
Modified
|
aiortc~aioquic
|
1519aec9ff7c8a04addfe641d7fd3b1c3160c99c
|
[config] make connection ID length configurable
|
<4>:<add> header = pull_quic_header(
<del> header = pull_quic_header(buf, host_cid_length=8)
<5>:<add> buf, host_cid_length=self._configuration.connection_id_length
<add> )
|
# module: aioquic.asyncio.server
class QuicServer(asyncio.DatagramProtocol):
def datagram_received(self, data: Union[bytes, Text], addr: NetworkAddress) -> None:
<0> data = cast(bytes, data)
<1> buf = Buffer(data=data)
<2>
<3> try:
<4> header = pull_quic_header(buf, host_cid_length=8)
<5> except ValueError:
<6> return
<7>
<8> # version negotiation
<9> if (
<10> header.version is not None
<11> and header.version not in self._configuration.supported_versions
<12> ):
<13> self._transport.sendto(
<14> encode_quic_version_negotiation(
<15> source_cid=header.destination_cid,
<16> destination_cid=header.source_cid,
<17> supported_versions=self._configuration.supported_versions,
<18> ),
<19> addr,
<20> )
<21> return
<22>
<23> protocol = self._protocols.get(header.destination_cid, None)
<24> original_connection_id: Optional[bytes] = None
<25> if (
<26> protocol is None
<27> and len(data) >= 1200
<28> and header.packet_type == PACKET_TYPE_INITIAL
<29> ):
<30> # stateless retry
<31> if self._retry is not None:
<32> if not header.token:
<33> # create a retry token
<34> self._transport.sendto(
<35> encode_quic_retry(
<36> version=header.version,
<37> source_cid=os.urandom(8),
<38> destination_cid=header.source_cid,
<39> original_destination_cid=header.destination_cid,
<40> retry_token=self._retry.create_token(
<41> addr, header.destination_cid
<42> ),
<43> ),
<44> addr,
<45> )
<46> return
<47> else:
<48> # validate retry token
<49> try:
<50> original_connection_id = self._retry.validate_token(
<51> addr, header</s>
|
===========below chunk 0===========
# module: aioquic.asyncio.server
class QuicServer(asyncio.DatagramProtocol):
def datagram_received(self, data: Union[bytes, Text], addr: NetworkAddress) -> None:
# offset: 1
)
except ValueError:
return
# create new connection
connection = QuicConnection(
configuration=self._configuration,
logger_connection_id=original_connection_id or header.destination_cid,
original_connection_id=original_connection_id,
session_ticket_fetcher=self._session_ticket_fetcher,
session_ticket_handler=self._session_ticket_handler,
)
protocol = self._create_protocol(
connection, stream_handler=self._stream_handler
)
protocol.connection_made(self._transport)
# register callbacks
protocol._connection_id_issued_handler = partial(
self._connection_id_issued, protocol=protocol
)
protocol._connection_id_retired_handler = partial(
self._connection_id_retired, protocol=protocol
)
protocol._connection_terminated_handler = partial(
self._connection_terminated, protocol=protocol
)
self._protocols[header.destination_cid] = protocol
self._protocols[connection.host_cid] = protocol
if protocol is not None:
protocol.datagram_received(data, addr)
===========unchanged ref 0===========
at: aioquic._buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic.asyncio.server.QuicServer
_connection_id_issued(cid: bytes, protocol: QuicConnectionProtocol)
_connection_id_retired(cid: bytes, protocol: QuicConnectionProtocol) -> None
_connection_terminated(protocol: QuicConnectionProtocol)
at: aioquic.asyncio.server.QuicServer.__init__
self._configuration = configuration
self._create_protocol = create_protocol
self._protocols: Dict[bytes, QuicConnectionProtocol] = {}
self._session_ticket_fetcher = session_ticket_fetcher
self._session_ticket_handler = session_ticket_handler
self._transport: Optional[asyncio.DatagramTransport] = None
self._stream_handler = stream_handler
self._retry = QuicRetryTokenHandler()
self._retry = None
at: aioquic.asyncio.server.QuicServer.connection_made
self._transport = cast(asyncio.DatagramTransport, transport)
at: aioquic.quic.configuration.QuicConfiguration
alpn_protocols: Optional[List[str]] = None
certificate: Any = None
connection_id_length: int = 8
idle_timeout: float = 60.0
is_client: bool = True
private_key: Any = None
quic_logger: Optional[QuicLogger] = None
secrets_log_file: TextIO = None
server_name: Optional[str] = None
session_ticket: Optional[SessionTicket] = None
supported_versions: List[int] = field(
default_factory=lambda: [QuicProtocolVersion.DRAFT_22]
)
at: aioquic.quic.connection
NetworkAddress = Any
===========unchanged ref 1===========
QuicConnection(*, configuration: QuicConfiguration, logger_connection_id: Optional[bytes]=None, original_connection_id: Optional[bytes]=None, session_ticket_fetcher: Optional[tls.SessionTicketFetcher]=None, session_ticket_handler: Optional[tls.SessionTicketHandler]=None)
at: aioquic.quic.connection.QuicConnection.__init__
self.host_cid = self._host_cids[0].cid
at: aioquic.quic.connection.QuicConnection.receive_datagram
self.host_cid = context.host_cid
at: aioquic.quic.packet
PACKET_TYPE_INITIAL = PACKET_LONG_HEADER | PACKET_FIXED_BIT | 0x00
pull_quic_header(buf: Buffer, host_cid_length: Optional[int]=None) -> QuicHeader
encode_quic_retry(version: int, source_cid: bytes, destination_cid: bytes, original_destination_cid: bytes, retry_token: bytes) -> bytes
encode_quic_version_negotiation(source_cid: bytes, destination_cid: bytes, supported_versions: List[int]) -> bytes
at: aioquic.quic.packet.QuicHeader
is_long_header: bool
version: Optional[int]
packet_type: int
destination_cid: bytes
source_cid: bytes
original_destination_cid: bytes = b""
token: bytes = b""
rest_length: int = 0
at: aioquic.quic.retry.QuicRetryTokenHandler
create_token(addr: NetworkAddress, destination_cid: bytes) -> bytes
validate_token(addr: NetworkAddress, token: bytes) -> bytes
at: asyncio.protocols.DatagramProtocol
__slots__ = ()
datagram_received(self, data: bytes, addr: Tuple[str, int]) -> None
at: asyncio.transports.DatagramTransport
__slots__ = ()
===========unchanged ref 2===========
sendto(data: Any, addr: Optional[_Address]=...) -> None
at: functools
partial(func: Callable[..., _T], *args: Any, **kwargs: Any)
partial(func, *args, **keywords, /) -> function with partial application()
at: os
urandom(size: int, /) -> bytes
at: typing
cast(typ: Type[_T], val: Any) -> _T
cast(typ: str, val: Any) -> Any
cast(typ: object, val: Any) -> Any
Text = str
at: typing.Mapping
get(key: _KT, default: Union[_VT_co, _T]) -> Union[_VT_co, _T]
get(key: _KT) -> Optional[_VT_co]
===========changed ref 0===========
# module: aioquic.quic.connection
class QuicConnection:
def _replenish_connection_ids(self) -> None:
"""
Generate new connection IDs.
"""
while len(self._host_cids) < min(8, self._remote_active_connection_id_limit):
self._host_cids.append(
QuicConnectionId(
+ cid=os.urandom(self._configuration.connection_id_length),
- cid=os.urandom(8),
sequence_number=self._host_cid_seq,
stateless_reset_token=os.urandom(16),
)
)
self._host_cid_seq += 1
|
aioquic.quic.packet/pull_quic_transport_parameters
|
Modified
|
aiortc~aioquic
|
ee4a2c33f4b32b332c9f5e7ea86ef619258ce9ed
|
[packet] parse and serialize PreferredAddress parameter
|
<15>:<add> elif param_type == QuicPreferredAddress:
<add> setattr(params, param_name, pull_quic_preferred_address(buf))
|
# module: aioquic.quic.packet
def pull_quic_transport_parameters(buf: Buffer) -> QuicTransportParameters:
<0> params = QuicTransportParameters()
<1>
<2> with pull_block(buf, 2) as length:
<3> end = buf.tell() + length
<4> while buf.tell() < end:
<5> param_id = buf.pull_uint16()
<6> param_len = buf.pull_uint16()
<7> param_start = buf.tell()
<8> if param_id < len(PARAMS):
<9> # parse known parameter
<10> param_name, param_type = PARAMS[param_id]
<11> if param_type == int:
<12> setattr(params, param_name, buf.pull_uint_var())
<13> elif param_type == bytes:
<14> setattr(params, param_name, buf.pull_bytes(param_len))
<15> else:
<16> setattr(params, param_name, True)
<17> else:
<18> # skip unknown parameter
<19> buf.pull_bytes(param_len)
<20> assert buf.tell() == param_start + param_len
<21>
<22> return params
<23>
|
===========unchanged ref 0===========
at: aioquic._buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic._buffer.Buffer
pull_bytes(length: int) -> bytes
pull_uint8() -> int
pull_uint16() -> int
at: aioquic.quic.packet
QuicPreferredAddress(ipv4_address: Optional[Tuple[str, int]], ipv6_address: Optional[Tuple[str, int]], connection_id: bytes, stateless_reset_token: bytes)
at: aioquic.quic.packet.QuicPreferredAddress
ipv4_address: Optional[Tuple[str, int]]
ipv6_address: Optional[Tuple[str, int]]
connection_id: bytes
stateless_reset_token: bytes
at: ipaddress
IPv4Address(address: object)
IPv6Address(address: object)
===========changed ref 0===========
# module: aioquic.quic.packet
+ # TLS EXTENSION
+
+
+ @dataclass
+ class QuicPreferredAddress:
+ ipv4_address: Optional[Tuple[str, int]]
+ ipv6_address: Optional[Tuple[str, int]]
+ connection_id: bytes
+ stateless_reset_token: bytes
+
===========changed ref 1===========
# module: aioquic.quic.packet
PARAMS = [
("original_connection_id", bytes),
("idle_timeout", int),
("stateless_reset_token", bytes),
("max_packet_size", int),
("initial_max_data", int),
("initial_max_stream_data_bidi_local", int),
("initial_max_stream_data_bidi_remote", int),
("initial_max_stream_data_uni", int),
("initial_max_streams_bidi", int),
("initial_max_streams_uni", int),
("ack_delay_exponent", int),
("max_ack_delay", int),
("disable_migration", bool),
+ ("preferred_address", QuicPreferredAddress),
- ("preferred_address", bytes),
("active_connection_id_limit", int),
]
===========changed ref 2===========
# module: aioquic.quic.packet
- # TLS EXTENSION
-
-
@dataclass
class QuicTransportParameters:
- initial_version: Optional[QuicProtocolVersion] = None
- negotiated_version: Optional[QuicProtocolVersion] = None
- supported_versions: List[QuicProtocolVersion] = field(default_factory=list)
-
original_connection_id: Optional[bytes] = None
idle_timeout: Optional[int] = None
stateless_reset_token: Optional[bytes] = None
max_packet_size: Optional[int] = None
initial_max_data: Optional[int] = None
initial_max_stream_data_bidi_local: Optional[int] = None
initial_max_stream_data_bidi_remote: Optional[int] = None
initial_max_stream_data_uni: Optional[int] = None
initial_max_streams_bidi: Optional[int] = None
initial_max_streams_uni: Optional[int] = None
ack_delay_exponent: Optional[int] = None
max_ack_delay: Optional[int] = None
disable_migration: Optional[bool] = False
+ preferred_address: Optional[QuicPreferredAddress] = None
- preferred_address: Optional[bytes] = None
active_connection_id_limit: Optional[int] = None
|
aioquic.quic.packet/push_quic_transport_parameters
|
Modified
|
aiortc~aioquic
|
ee4a2c33f4b32b332c9f5e7ea86ef619258ce9ed
|
[packet] parse and serialize PreferredAddress parameter
|
<10>:<add> elif param_type == QuicPreferredAddress:
<add> push_quic_preferred_address(buf, param_value)
|
# module: aioquic.quic.packet
def push_quic_transport_parameters(
buf: Buffer, params: QuicTransportParameters
) -> None:
<0> with push_block(buf, 2):
<1> for param_id, (param_name, param_type) in enumerate(PARAMS):
<2> param_value = getattr(params, param_name)
<3> if param_value is not None and param_value is not False:
<4> buf.push_uint16(param_id)
<5> with push_block(buf, 2):
<6> if param_type == int:
<7> buf.push_uint_var(param_value)
<8> elif param_type == bytes:
<9> buf.push_bytes(param_value)
<10>
|
===========unchanged ref 0===========
at: aioquic._buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic._buffer.Buffer
push_bytes(value: bytes) -> None
push_uint16(value: int) -> None
at: aioquic.quic.packet
QuicPreferredAddress(ipv4_address: Optional[Tuple[str, int]], ipv6_address: Optional[Tuple[str, int]], connection_id: bytes, stateless_reset_token: bytes)
at: aioquic.quic.packet.QuicPreferredAddress
ipv4_address: Optional[Tuple[str, int]]
at: aioquic.quic.packet.pull_quic_preferred_address
stateless_reset_token = buf.pull_bytes(16)
at: ipaddress
IPv4Address(address: object)
at: ipaddress.IPv4Address
__slots__ = ('_ip', '__weakref__')
===========changed ref 0===========
# module: aioquic.quic.packet
+ # TLS EXTENSION
+
+
+ @dataclass
+ class QuicPreferredAddress:
+ ipv4_address: Optional[Tuple[str, int]]
+ ipv6_address: Optional[Tuple[str, int]]
+ connection_id: bytes
+ stateless_reset_token: bytes
+
===========changed ref 1===========
# module: aioquic.quic.packet
PARAMS = [
("original_connection_id", bytes),
("idle_timeout", int),
("stateless_reset_token", bytes),
("max_packet_size", int),
("initial_max_data", int),
("initial_max_stream_data_bidi_local", int),
("initial_max_stream_data_bidi_remote", int),
("initial_max_stream_data_uni", int),
("initial_max_streams_bidi", int),
("initial_max_streams_uni", int),
("ack_delay_exponent", int),
("max_ack_delay", int),
("disable_migration", bool),
+ ("preferred_address", QuicPreferredAddress),
- ("preferred_address", bytes),
("active_connection_id_limit", int),
]
===========changed ref 2===========
# module: aioquic.quic.packet
+ def pull_quic_preferred_address(buf: Buffer) -> QuicPreferredAddress:
+ ipv4_address = None
+ ipv4_host = buf.pull_bytes(4)
+ ipv4_port = buf.pull_uint16()
+ if ipv4_host != bytes(4):
+ ipv4_address = (str(ipaddress.IPv4Address(ipv4_host)), ipv4_port)
+
+ ipv6_address = None
+ ipv6_host = buf.pull_bytes(16)
+ ipv6_port = buf.pull_uint16()
+ if ipv6_host != bytes(16):
+ ipv6_address = (str(ipaddress.IPv6Address(ipv6_host)), ipv6_port)
+
+ connection_id_length = buf.pull_uint8()
+ connection_id = buf.pull_bytes(connection_id_length)
+ stateless_reset_token = buf.pull_bytes(16)
+
+ return QuicPreferredAddress(
+ ipv4_address=ipv4_address,
+ ipv6_address=ipv6_address,
+ connection_id=connection_id,
+ stateless_reset_token=stateless_reset_token,
+ )
+
===========changed ref 3===========
# module: aioquic.quic.packet
def pull_quic_transport_parameters(buf: Buffer) -> QuicTransportParameters:
params = QuicTransportParameters()
with pull_block(buf, 2) as length:
end = buf.tell() + length
while buf.tell() < end:
param_id = buf.pull_uint16()
param_len = buf.pull_uint16()
param_start = buf.tell()
if param_id < len(PARAMS):
# parse known parameter
param_name, param_type = PARAMS[param_id]
if param_type == int:
setattr(params, param_name, buf.pull_uint_var())
elif param_type == bytes:
setattr(params, param_name, buf.pull_bytes(param_len))
+ elif param_type == QuicPreferredAddress:
+ setattr(params, param_name, pull_quic_preferred_address(buf))
else:
setattr(params, param_name, True)
else:
# skip unknown parameter
buf.pull_bytes(param_len)
assert buf.tell() == param_start + param_len
return params
===========changed ref 4===========
# module: aioquic.quic.packet
- # TLS EXTENSION
-
-
@dataclass
class QuicTransportParameters:
- initial_version: Optional[QuicProtocolVersion] = None
- negotiated_version: Optional[QuicProtocolVersion] = None
- supported_versions: List[QuicProtocolVersion] = field(default_factory=list)
-
original_connection_id: Optional[bytes] = None
idle_timeout: Optional[int] = None
stateless_reset_token: Optional[bytes] = None
max_packet_size: Optional[int] = None
initial_max_data: Optional[int] = None
initial_max_stream_data_bidi_local: Optional[int] = None
initial_max_stream_data_bidi_remote: Optional[int] = None
initial_max_stream_data_uni: Optional[int] = None
initial_max_streams_bidi: Optional[int] = None
initial_max_streams_uni: Optional[int] = None
ack_delay_exponent: Optional[int] = None
max_ack_delay: Optional[int] = None
disable_migration: Optional[bool] = False
+ preferred_address: Optional[QuicPreferredAddress] = None
- preferred_address: Optional[bytes] = None
active_connection_id_limit: Optional[int] = None
|
aioquic.tls/SessionTicket.is_valid
|
Modified
|
aiortc~aioquic
|
27110985b19fbdac2f272abe8beb1d0a92218bd3
|
[tls] start adding code to verify certificate
|
<0>:<add> now = utcnow()
<del> now = datetime.datetime.now()
|
# module: aioquic.tls
# callback types
@dataclass
class SessionTicket:
@property
def is_valid(self) -> bool:
<0> now = datetime.datetime.now()
<1> return now > self.not_valid_before and now < self.not_valid_after
<2>
|
===========unchanged ref 0===========
at: aioquic.tls
SignatureAlgorithm(x: Union[str, bytes, bytearray], base: int)
SignatureAlgorithm(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
SIGNATURE_ALGORITHMS = {
SignatureAlgorithm.ECDSA_SECP256R1_SHA256: (None, hashes.SHA256),
SignatureAlgorithm.ECDSA_SECP384R1_SHA384: (None, hashes.SHA384),
SignatureAlgorithm.ECDSA_SECP521R1_SHA512: (None, hashes.SHA512),
SignatureAlgorithm.RSA_PKCS1_SHA1: (padding.PKCS1v15, hashes.SHA1),
SignatureAlgorithm.RSA_PKCS1_SHA256: (padding.PKCS1v15, hashes.SHA256),
SignatureAlgorithm.RSA_PKCS1_SHA384: (padding.PKCS1v15, hashes.SHA384),
SignatureAlgorithm.RSA_PKCS1_SHA512: (padding.PKCS1v15, hashes.SHA512),
SignatureAlgorithm.RSA_PSS_RSAE_SHA256: (padding.PSS, hashes.SHA256),
SignatureAlgorithm.RSA_PSS_RSAE_SHA384: (padding.PSS, hashes.SHA384),
SignatureAlgorithm.RSA_PSS_RSAE_SHA512: (padding.PSS, hashes.SHA512),
}
at: typing
Tuple = _TupleType(tuple, -1, inst=False, name='Tuple')
===========changed ref 0===========
# module: aioquic.tls
+ class AlertCertificateExpired(Alert):
+ description = AlertDescription.certificate_expired
+
===========changed ref 1===========
# module: aioquic.tls
+ class AlertBadCertificate(Alert):
+ description = AlertDescription.bad_certificate
+
===========changed ref 2===========
# module: aioquic.tls
TLS_VERSION_1_2 = 0x0303
TLS_VERSION_1_3 = 0x0304
TLS_VERSION_1_3_DRAFT_28 = 0x7F1C
TLS_VERSION_1_3_DRAFT_27 = 0x7F1B
TLS_VERSION_1_3_DRAFT_26 = 0x7F1A
T = TypeVar("T")
+ # facilitate mocking for the test suite
+ utcnow = datetime.datetime.utcnow
+
===========changed ref 3===========
# module: aioquic.tls
+ def verify_certificate(
+ certificate: x509.Certificate, server_name: Optional[str]
+ ) -> None:
+ # verify dates
+ now = utcnow()
+ if now < certificate.not_valid_before:
+ raise AlertCertificateExpired("Certificate is not valid yet")
+ if now > certificate.not_valid_after:
+ raise AlertCertificateExpired("Certificate is no longer valid")
+
+ # verify subject
+ if server_name is not None:
+ subject = []
+ subjectAltName: List[Tuple[str, str]] = []
+ for attr in certificate.subject:
+ if attr.oid == x509.NameOID.COMMON_NAME:
+ subject.append((("commonName", attr.value),))
+ for ext in certificate.extensions:
+ if ext.oid == x509.ExtensionOID.SUBJECT_ALTERNATIVE_NAME:
+ for name in ext.value:
+ if isinstance(name, x509.DNSName):
+ subjectAltName.append(("DNS", name.value))
+
+ try:
+ ssl.match_hostname(
+ {"subject": tuple(subject), "subjectAltName": tuple(subjectAltName)},
+ server_name,
+ )
+ except ssl.CertificateError as exc:
+ raise AlertBadCertificate("\n".join(exc.args)) from exc
+
|
aioquic.tls/SessionTicket.obfuscated_age
|
Modified
|
aiortc~aioquic
|
27110985b19fbdac2f272abe8beb1d0a92218bd3
|
[tls] start adding code to verify certificate
|
<0>:<add> age = int((utcnow() - self.not_valid_before).total_seconds())
<del> age = int((datetime.datetime.now() - self.not_valid_before).total_seconds())
|
# module: aioquic.tls
# callback types
@dataclass
class SessionTicket:
@property
def obfuscated_age(self) -> int:
<0> age = int((datetime.datetime.now() - self.not_valid_before).total_seconds())
<1> return (age + self.age_add) % (1 << 32)
<2>
|
===========unchanged ref 0===========
at: aioquic.tls.signature_algorithm_params
padding_cls, algorithm_cls = SIGNATURE_ALGORITHMS[signature_algorithm]
algorithm = algorithm_cls()
===========changed ref 0===========
# module: aioquic.tls
# callback types
@dataclass
class SessionTicket:
@property
def is_valid(self) -> bool:
+ now = utcnow()
- now = datetime.datetime.now()
return now > self.not_valid_before and now < self.not_valid_after
===========changed ref 1===========
# module: aioquic.tls
+ class AlertCertificateExpired(Alert):
+ description = AlertDescription.certificate_expired
+
===========changed ref 2===========
# module: aioquic.tls
+ class AlertBadCertificate(Alert):
+ description = AlertDescription.bad_certificate
+
===========changed ref 3===========
# module: aioquic.tls
TLS_VERSION_1_2 = 0x0303
TLS_VERSION_1_3 = 0x0304
TLS_VERSION_1_3_DRAFT_28 = 0x7F1C
TLS_VERSION_1_3_DRAFT_27 = 0x7F1B
TLS_VERSION_1_3_DRAFT_26 = 0x7F1A
T = TypeVar("T")
+ # facilitate mocking for the test suite
+ utcnow = datetime.datetime.utcnow
+
===========changed ref 4===========
# module: aioquic.tls
+ def verify_certificate(
+ certificate: x509.Certificate, server_name: Optional[str]
+ ) -> None:
+ # verify dates
+ now = utcnow()
+ if now < certificate.not_valid_before:
+ raise AlertCertificateExpired("Certificate is not valid yet")
+ if now > certificate.not_valid_after:
+ raise AlertCertificateExpired("Certificate is no longer valid")
+
+ # verify subject
+ if server_name is not None:
+ subject = []
+ subjectAltName: List[Tuple[str, str]] = []
+ for attr in certificate.subject:
+ if attr.oid == x509.NameOID.COMMON_NAME:
+ subject.append((("commonName", attr.value),))
+ for ext in certificate.extensions:
+ if ext.oid == x509.ExtensionOID.SUBJECT_ALTERNATIVE_NAME:
+ for name in ext.value:
+ if isinstance(name, x509.DNSName):
+ subjectAltName.append(("DNS", name.value))
+
+ try:
+ ssl.match_hostname(
+ {"subject": tuple(subject), "subjectAltName": tuple(subjectAltName)},
+ server_name,
+ )
+ except ssl.CertificateError as exc:
+ raise AlertBadCertificate("\n".join(exc.args)) from exc
+
|
aioquic.tls/Context._build_session_ticket
|
Modified
|
aiortc~aioquic
|
27110985b19fbdac2f272abe8beb1d0a92218bd3
|
[tls] start adding code to verify certificate
|
<9>:<add> timestamp = utcnow()
<del> timestamp = datetime.datetime.now()
|
# module: aioquic.tls
class Context:
def _build_session_ticket(
self, new_session_ticket: NewSessionTicket
) -> SessionTicket:
<0> resumption_master_secret = self.key_schedule.derive_secret(b"res master")
<1> resumption_secret = hkdf_expand_label(
<2> algorithm=self.key_schedule.algorithm,
<3> secret=resumption_master_secret,
<4> label=b"resumption",
<5> hash_value=new_session_ticket.ticket_nonce,
<6> length=self.key_schedule.algorithm.digest_size,
<7> )
<8>
<9> timestamp = datetime.datetime.now()
<10> return SessionTicket(
<11> age_add=new_session_ticket.ticket_age_add,
<12> cipher_suite=self.key_schedule.cipher_suite,
<13> max_early_data_size=new_session_ticket.max_early_data_size,
<14> not_valid_after=timestamp
<15> + datetime.timedelta(seconds=new_session_ticket.ticket_lifetime),
<16> not_valid_before=timestamp,
<17> other_extensions=self.handshake_extensions,
<18> resumption_secret=resumption_secret,
<19> server_name=self.server_name,
<20> ticket=new_session_ticket.ticket,
<21> )
<22>
|
===========unchanged ref 0===========
at: aioquic.tls
AlertUnexpectedMessage(*args: object)
Epoch()
State()
HandshakeType(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
HandshakeType(x: Union[str, bytes, bytearray], base: int)
at: aioquic.tls.Context
_client_handle_certificate(input_buf: Buffer) -> None
_client_handle_certificate_verify(input_buf: Buffer) -> None
_client_handle_finished(input_buf: Buffer, output_buf: Buffer) -> None
_client_handle_new_session_ticket(input_buf: Buffer) -> None
at: aioquic.tls.Context.__init__
self.state = State.CLIENT_HANDSHAKE_START
self.state = State.SERVER_EXPECT_CLIENT_HELLO
at: aioquic.tls.Context._set_state
self.state = state
at: aioquic.tls.Context.handle_message
message_type = self._receive_buffer[0]
input_buf = Buffer(data=message)
===========changed ref 0===========
# module: aioquic.tls
# callback types
@dataclass
class SessionTicket:
@property
def is_valid(self) -> bool:
+ now = utcnow()
- now = datetime.datetime.now()
return now > self.not_valid_before and now < self.not_valid_after
===========changed ref 1===========
# module: aioquic.tls
# callback types
@dataclass
class SessionTicket:
@property
def obfuscated_age(self) -> int:
+ age = int((utcnow() - self.not_valid_before).total_seconds())
- age = int((datetime.datetime.now() - self.not_valid_before).total_seconds())
return (age + self.age_add) % (1 << 32)
===========changed ref 2===========
# module: aioquic.tls
+ class AlertCertificateExpired(Alert):
+ description = AlertDescription.certificate_expired
+
===========changed ref 3===========
# module: aioquic.tls
+ class AlertBadCertificate(Alert):
+ description = AlertDescription.bad_certificate
+
===========changed ref 4===========
# module: aioquic.tls
TLS_VERSION_1_2 = 0x0303
TLS_VERSION_1_3 = 0x0304
TLS_VERSION_1_3_DRAFT_28 = 0x7F1C
TLS_VERSION_1_3_DRAFT_27 = 0x7F1B
TLS_VERSION_1_3_DRAFT_26 = 0x7F1A
T = TypeVar("T")
+ # facilitate mocking for the test suite
+ utcnow = datetime.datetime.utcnow
+
===========changed ref 5===========
# module: aioquic.tls
+ def verify_certificate(
+ certificate: x509.Certificate, server_name: Optional[str]
+ ) -> None:
+ # verify dates
+ now = utcnow()
+ if now < certificate.not_valid_before:
+ raise AlertCertificateExpired("Certificate is not valid yet")
+ if now > certificate.not_valid_after:
+ raise AlertCertificateExpired("Certificate is no longer valid")
+
+ # verify subject
+ if server_name is not None:
+ subject = []
+ subjectAltName: List[Tuple[str, str]] = []
+ for attr in certificate.subject:
+ if attr.oid == x509.NameOID.COMMON_NAME:
+ subject.append((("commonName", attr.value),))
+ for ext in certificate.extensions:
+ if ext.oid == x509.ExtensionOID.SUBJECT_ALTERNATIVE_NAME:
+ for name in ext.value:
+ if isinstance(name, x509.DNSName):
+ subjectAltName.append(("DNS", name.value))
+
+ try:
+ ssl.match_hostname(
+ {"subject": tuple(subject), "subjectAltName": tuple(subjectAltName)},
+ server_name,
+ )
+ except ssl.CertificateError as exc:
+ raise AlertBadCertificate("\n".join(exc.args)) from exc
+
|
tests.test_tls/generate_ec_certificate
|
Modified
|
aiortc~aioquic
|
27110985b19fbdac2f272abe8beb1d0a92218bd3
|
[tls] start adding code to verify certificate
|
<3>:<add> [x509.NameAttribute(x509.NameOID.COMMON_NAME, common_name)]
<del> [x509.NameAttribute(x509.NameOID.COMMON_NAME, "example.com")]
<6>:<add> builder = (
<del> cert = (
<14>:<del> .sign(key, hashes.SHA256(), default_backend())
<16>:<add> if alternative_names:
<add> builder = builder.add_extension(
<add> x509.SubjectAlternativeName(
<add> [x509.DNSName(name) for name in alternative_names]
<add> ),
<add> critical=False,
<add> )
<add> cert = builder.sign(key, hashes.SHA256(), default_backend())
|
# module: tests.test_tls
+ def generate_ec_certificate(common_name, curve, alternative_names=[]):
- def generate_ec_certificate(curve):
<0> key = ec.generate_private_key(backend=default_backend(), curve=curve)
<1>
<2> subject = issuer = x509.Name(
<3> [x509.NameAttribute(x509.NameOID.COMMON_NAME, "example.com")]
<4> )
<5>
<6> cert = (
<7> x509.CertificateBuilder()
<8> .subject_name(subject)
<9> .issuer_name(issuer)
<10> .public_key(key.public_key())
<11> .serial_number(x509.random_serial_number())
<12> .not_valid_before(datetime.datetime.utcnow())
<13> .not_valid_after(datetime.datetime.utcnow() + datetime.timedelta(days=10))
<14> .sign(key, hashes.SHA256(), default_backend())
<15> )
<16> return cert, key
<17>
|
===========unchanged ref 0===========
at: datetime
timedelta(days: float=..., seconds: float=..., microseconds: float=..., milliseconds: float=..., minutes: float=..., hours: float=..., weeks: float=..., *, fold: int=...)
datetime()
at: datetime.datetime
__slots__ = date.__slots__ + time.__slots__
utcnow() -> _S
__radd__ = __add__
at: datetime.timedelta
__slots__ = '_days', '_seconds', '_microseconds', '_hashcode'
__radd__ = __add__
__rmul__ = __mul__
===========changed ref 0===========
# module: aioquic.tls
+ class AlertCertificateExpired(Alert):
+ description = AlertDescription.certificate_expired
+
===========changed ref 1===========
# module: aioquic.tls
+ class AlertBadCertificate(Alert):
+ description = AlertDescription.bad_certificate
+
===========changed ref 2===========
# module: aioquic.tls
# callback types
@dataclass
class SessionTicket:
@property
def is_valid(self) -> bool:
+ now = utcnow()
- now = datetime.datetime.now()
return now > self.not_valid_before and now < self.not_valid_after
===========changed ref 3===========
# module: aioquic.tls
# callback types
@dataclass
class SessionTicket:
@property
def obfuscated_age(self) -> int:
+ age = int((utcnow() - self.not_valid_before).total_seconds())
- age = int((datetime.datetime.now() - self.not_valid_before).total_seconds())
return (age + self.age_add) % (1 << 32)
===========changed ref 4===========
# module: aioquic.tls
TLS_VERSION_1_2 = 0x0303
TLS_VERSION_1_3 = 0x0304
TLS_VERSION_1_3_DRAFT_28 = 0x7F1C
TLS_VERSION_1_3_DRAFT_27 = 0x7F1B
TLS_VERSION_1_3_DRAFT_26 = 0x7F1A
T = TypeVar("T")
+ # facilitate mocking for the test suite
+ utcnow = datetime.datetime.utcnow
+
===========changed ref 5===========
# module: aioquic.tls
+ def verify_certificate(
+ certificate: x509.Certificate, server_name: Optional[str]
+ ) -> None:
+ # verify dates
+ now = utcnow()
+ if now < certificate.not_valid_before:
+ raise AlertCertificateExpired("Certificate is not valid yet")
+ if now > certificate.not_valid_after:
+ raise AlertCertificateExpired("Certificate is no longer valid")
+
+ # verify subject
+ if server_name is not None:
+ subject = []
+ subjectAltName: List[Tuple[str, str]] = []
+ for attr in certificate.subject:
+ if attr.oid == x509.NameOID.COMMON_NAME:
+ subject.append((("commonName", attr.value),))
+ for ext in certificate.extensions:
+ if ext.oid == x509.ExtensionOID.SUBJECT_ALTERNATIVE_NAME:
+ for name in ext.value:
+ if isinstance(name, x509.DNSName):
+ subjectAltName.append(("DNS", name.value))
+
+ try:
+ ssl.match_hostname(
+ {"subject": tuple(subject), "subjectAltName": tuple(subjectAltName)},
+ server_name,
+ )
+ except ssl.CertificateError as exc:
+ raise AlertBadCertificate("\n".join(exc.args)) from exc
+
===========changed ref 6===========
# module: aioquic.tls
class Context:
def _build_session_ticket(
self, new_session_ticket: NewSessionTicket
) -> SessionTicket:
resumption_master_secret = self.key_schedule.derive_secret(b"res master")
resumption_secret = hkdf_expand_label(
algorithm=self.key_schedule.algorithm,
secret=resumption_master_secret,
label=b"resumption",
hash_value=new_session_ticket.ticket_nonce,
length=self.key_schedule.algorithm.digest_size,
)
+ timestamp = utcnow()
- timestamp = datetime.datetime.now()
return SessionTicket(
age_add=new_session_ticket.ticket_age_add,
cipher_suite=self.key_schedule.cipher_suite,
max_early_data_size=new_session_ticket.max_early_data_size,
not_valid_after=timestamp
+ datetime.timedelta(seconds=new_session_ticket.ticket_lifetime),
not_valid_before=timestamp,
other_extensions=self.handshake_extensions,
resumption_secret=resumption_secret,
server_name=self.server_name,
ticket=new_session_ticket.ticket,
)
|
tests.test_tls/ContextTest.test_handshake_ecdsa_secp256r1
|
Modified
|
aiortc~aioquic
|
27110985b19fbdac2f272abe8beb1d0a92218bd3
|
[tls] start adding code to verify certificate
|
<3>:<add> common_name="example.com", curve=ec.SECP256R1
<del> ec.SECP256R1
|
# module: tests.test_tls
class ContextTest(TestCase):
def test_handshake_ecdsa_secp256r1(self):
<0> client = self.create_client()
<1> server = self.create_server()
<2> server.certificate, server.certificate_private_key = generate_ec_certificate(
<3> ec.SECP256R1
<4> )
<5>
<6> self._handshake(client, server)
<7>
<8> # check ALPN matches
<9> self.assertEqual(client.alpn_negotiated, None)
<10> self.assertEqual(server.alpn_negotiated, None)
<11>
|
===========unchanged ref 0===========
at: aioquic.tls.Context.__init__
self.alpn_negotiated: Optional[str] = None
at: aioquic.tls.Context._client_handle_encrypted_extensions
self.alpn_negotiated = encrypted_extensions.alpn_protocol
at: aioquic.tls.Context._server_handle_hello
self.alpn_negotiated = negotiate(
self.alpn_protocols,
peer_hello.alpn_protocols,
AlertHandshakeFailure("No common ALPN protocols"),
)
at: tests.test_tls.ContextTest
create_client()
create_server()
_handshake(client, server)
at: unittest.case.TestCase
failureException: Type[BaseException]
longMessage: bool
maxDiff: Optional[int]
_testMethodName: str
_testMethodDoc: str
assertEqual(first: Any, second: Any, msg: Any=...) -> None
===========changed ref 0===========
# module: tests.test_tls
+ def generate_ec_certificate(common_name, curve, alternative_names=[]):
- def generate_ec_certificate(curve):
key = ec.generate_private_key(backend=default_backend(), curve=curve)
subject = issuer = x509.Name(
+ [x509.NameAttribute(x509.NameOID.COMMON_NAME, common_name)]
- [x509.NameAttribute(x509.NameOID.COMMON_NAME, "example.com")]
)
+ builder = (
- cert = (
x509.CertificateBuilder()
.subject_name(subject)
.issuer_name(issuer)
.public_key(key.public_key())
.serial_number(x509.random_serial_number())
.not_valid_before(datetime.datetime.utcnow())
.not_valid_after(datetime.datetime.utcnow() + datetime.timedelta(days=10))
- .sign(key, hashes.SHA256(), default_backend())
)
+ if alternative_names:
+ builder = builder.add_extension(
+ x509.SubjectAlternativeName(
+ [x509.DNSName(name) for name in alternative_names]
+ ),
+ critical=False,
+ )
+ cert = builder.sign(key, hashes.SHA256(), default_backend())
return cert, key
===========changed ref 1===========
# module: aioquic.tls
+ class AlertCertificateExpired(Alert):
+ description = AlertDescription.certificate_expired
+
===========changed ref 2===========
# module: aioquic.tls
+ class AlertBadCertificate(Alert):
+ description = AlertDescription.bad_certificate
+
===========changed ref 3===========
# module: aioquic.tls
# callback types
@dataclass
class SessionTicket:
@property
def is_valid(self) -> bool:
+ now = utcnow()
- now = datetime.datetime.now()
return now > self.not_valid_before and now < self.not_valid_after
===========changed ref 4===========
# module: aioquic.tls
# callback types
@dataclass
class SessionTicket:
@property
def obfuscated_age(self) -> int:
+ age = int((utcnow() - self.not_valid_before).total_seconds())
- age = int((datetime.datetime.now() - self.not_valid_before).total_seconds())
return (age + self.age_add) % (1 << 32)
===========changed ref 5===========
# module: aioquic.tls
TLS_VERSION_1_2 = 0x0303
TLS_VERSION_1_3 = 0x0304
TLS_VERSION_1_3_DRAFT_28 = 0x7F1C
TLS_VERSION_1_3_DRAFT_27 = 0x7F1B
TLS_VERSION_1_3_DRAFT_26 = 0x7F1A
T = TypeVar("T")
+ # facilitate mocking for the test suite
+ utcnow = datetime.datetime.utcnow
+
===========changed ref 6===========
# module: aioquic.tls
+ def verify_certificate(
+ certificate: x509.Certificate, server_name: Optional[str]
+ ) -> None:
+ # verify dates
+ now = utcnow()
+ if now < certificate.not_valid_before:
+ raise AlertCertificateExpired("Certificate is not valid yet")
+ if now > certificate.not_valid_after:
+ raise AlertCertificateExpired("Certificate is no longer valid")
+
+ # verify subject
+ if server_name is not None:
+ subject = []
+ subjectAltName: List[Tuple[str, str]] = []
+ for attr in certificate.subject:
+ if attr.oid == x509.NameOID.COMMON_NAME:
+ subject.append((("commonName", attr.value),))
+ for ext in certificate.extensions:
+ if ext.oid == x509.ExtensionOID.SUBJECT_ALTERNATIVE_NAME:
+ for name in ext.value:
+ if isinstance(name, x509.DNSName):
+ subjectAltName.append(("DNS", name.value))
+
+ try:
+ ssl.match_hostname(
+ {"subject": tuple(subject), "subjectAltName": tuple(subjectAltName)},
+ server_name,
+ )
+ except ssl.CertificateError as exc:
+ raise AlertBadCertificate("\n".join(exc.args)) from exc
+
===========changed ref 7===========
# module: aioquic.tls
class Context:
def _build_session_ticket(
self, new_session_ticket: NewSessionTicket
) -> SessionTicket:
resumption_master_secret = self.key_schedule.derive_secret(b"res master")
resumption_secret = hkdf_expand_label(
algorithm=self.key_schedule.algorithm,
secret=resumption_master_secret,
label=b"resumption",
hash_value=new_session_ticket.ticket_nonce,
length=self.key_schedule.algorithm.digest_size,
)
+ timestamp = utcnow()
- timestamp = datetime.datetime.now()
return SessionTicket(
age_add=new_session_ticket.ticket_age_add,
cipher_suite=self.key_schedule.cipher_suite,
max_early_data_size=new_session_ticket.max_early_data_size,
not_valid_after=timestamp
+ datetime.timedelta(seconds=new_session_ticket.ticket_lifetime),
not_valid_before=timestamp,
other_extensions=self.handshake_extensions,
resumption_secret=resumption_secret,
server_name=self.server_name,
ticket=new_session_ticket.ticket,
)
|
aioquic.tls/SessionTicket.is_valid
|
Modified
|
aiortc~aioquic
|
cc25633b1e1c9feaff6a816b610d2ddee14e96f3
|
[tls] fix date check for session ticket validity
|
<1>:<add> return now >= self.not_valid_before and now <= self.not_valid_after
<del> return now > self.not_valid_before and now < self.not_valid_after
|
# module: aioquic.tls
# callback types
@dataclass
class SessionTicket:
@property
def is_valid(self) -> bool:
<0> now = utcnow()
<1> return now > self.not_valid_before and now < self.not_valid_after
<2>
|
===========unchanged ref 0===========
at: aioquic.tls
utcnow = datetime.datetime.utcnow
at: aioquic.tls.SessionTicket
age_add: int
cipher_suite: CipherSuite
not_valid_after: datetime.datetime
not_valid_before: datetime.datetime
resumption_secret: bytes
server_name: str
ticket: bytes
max_early_data_size: Optional[int] = None
other_extensions: List[Tuple[int, bytes]] = field(default_factory=list)
|
aioquic.quic.connection/QuicConnection._handle_padding_frame
|
Modified
|
aiortc~aioquic
|
ac608bb2a1b319c837b0c4018d5e9a9f6ed6344c
|
[connection] handle PADDING in the middle of a packet
|
<3>:<add> # consume padding
<add> pos = buf.tell()
<add> for byte in buf.data_slice(pos, buf.capacity):
<add> if byte:
<add> break
<add> pos += 1
<add> buf.seek(pos)
<del> buf.seek(buf.capacity)
|
# module: aioquic.quic.connection
class QuicConnection:
def _handle_padding_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
<0> """
<1> Handle a PADDING frame.
<2> """
<3> buf.seek(buf.capacity)
<4>
<5> # log frame
<6> if self._quic_logger is not None:
<7> context.quic_logger_frames.append(self._quic_logger.encode_padding_frame())
<8>
|
===========unchanged ref 0===========
at: aioquic._buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic._buffer.Buffer
data_slice(start: int, end: int) -> bytes
tell() -> int
at: aioquic.quic.connection
QuicReceiveContext(epoch: tls.Epoch, host_cid: bytes, network_path: QuicNetworkPath, quic_logger_frames: Optional[List[Any]], time: float)
|
aioquic.quic.logger/QuicLogger.__init__
|
Modified
|
aiortc~aioquic
|
6ba154bb3b33c9acb7c13f8457cb5cc1aba46c31
|
[logging] add a QuicLoggerTrace class
|
<0>:<del> self._odcid: bytes = b""
<1>:<del> self._events: Deque[Tuple[float, str, str, Dict[str, Any]]] = deque()
<2>:<del> self._vantage_point = {"name": "aioquic", "type": "unknown"}
<3>:<add> self._traces: List[QuicLoggerTrace] = []
|
# module: aioquic.quic.logger
class QuicLogger:
def __init__(self) -> None:
<0> self._odcid: bytes = b""
<1> self._events: Deque[Tuple[float, str, str, Dict[str, Any]]] = deque()
<2> self._vantage_point = {"name": "aioquic", "type": "unknown"}
<3>
|
===========unchanged ref 0===========
at: collections
deque(iterable: Iterable[_T]=..., maxlen: Optional[int]=...)
at: typing
Tuple = _TupleType(tuple, -1, inst=False, name='Tuple')
Deque = _alias(collections.deque, 1, name='Deque')
Dict = _alias(dict, 2, inst=False, name='Dict')
===========changed ref 0===========
# module: aioquic.quic.logger
+ class QuicLoggerTrace:
+ """
+ A QUIC event trace.
+
+ Events are logged in the format defined by qlog draft-01.
+
+ See: https://quiclog.github.io/internet-drafts/draft-marx-qlog-event-definitions-quic-h3.html
+ """
+
===========changed ref 1===========
# module: aioquic.quic.logger
+ class QuicLoggerTrace:
+ def __init__(self, *, is_client: bool, odcid: bytes) -> None:
+ self._odcid = odcid
+ self._events: Deque[Tuple[float, str, str, Dict[str, Any]]] = deque()
+ self._vantage_point = {
+ "name": "aioquic",
+ "type": "client" if is_client else "server",
+ }
+
|
aioquic.quic.logger/QuicLogger.start_trace
|
Modified
|
aiortc~aioquic
|
6ba154bb3b33c9acb7c13f8457cb5cc1aba46c31
|
[logging] add a QuicLoggerTrace class
|
<0>:<add> trace = QuicLoggerTrace(is_client=is_client, odcid=odcid)
<add> self._traces.append(trace)
<add> return trace
<del> self._odcid = odcid
<1>:<del> self._vantage_point["type"] = "client" if is_client else "server"
|
# module: aioquic.quic.logger
class QuicLogger:
+ def start_trace(self, is_client: bool, odcid: bytes) -> QuicLoggerTrace:
- def start_trace(self, is_client: bool, odcid: bytes) -> None:
<0> self._odcid = odcid
<1> self._vantage_point["type"] = "client" if is_client else "server"
<2>
|
===========unchanged ref 0===========
at: aioquic.quic.logger
PACKET_TYPE_NAMES = {
PACKET_TYPE_INITIAL: "initial",
PACKET_TYPE_HANDSHAKE: "handshake",
PACKET_TYPE_ZERO_RTT: "0RTT",
PACKET_TYPE_ONE_RTT: "1RTT",
PACKET_TYPE_RETRY: "retry",
}
at: aioquic.quic.packet
PACKET_TYPE_MASK = 0xF0
at: typing.Mapping
get(key: _KT, default: Union[_VT_co, _T]) -> Union[_VT_co, _T]
get(key: _KT) -> Optional[_VT_co]
===========changed ref 0===========
# module: aioquic.quic.logger
+ class QuicLoggerTrace:
+ def log_event(self, *, category: str, event: str, data: Dict) -> None:
+ self._events.append((time.time(), category, event, data))
+
===========changed ref 1===========
# module: aioquic.quic.logger
+ class QuicLoggerTrace:
+ def log_event(self, *, category: str, event: str, data: Dict) -> None:
+ self._events.append((time.time(), category, event, data))
+
===========changed ref 2===========
# module: aioquic.quic.logger
+ class QuicLoggerTrace:
+ def encode_streams_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "streams_blocked", "limit": str(limit)}
+
===========changed ref 3===========
# module: aioquic.quic.logger
+ class QuicLoggerTrace:
+ def encode_streams_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "streams_blocked", "limit": str(limit)}
+
===========changed ref 4===========
# module: aioquic.quic.logger
+ class QuicLoggerTrace:
+ def packet_type(self, packet_type: int) -> str:
+ return PACKET_TYPE_NAMES.get(packet_type & PACKET_TYPE_MASK, "1RTT")
+
===========changed ref 5===========
# module: aioquic.quic.logger
class QuicLogger:
- def encode_streams_blocked_frame(self, limit: int) -> Dict:
- return {"frame_type": "streams_blocked", "limit": str(limit)}
-
===========changed ref 6===========
# module: aioquic.quic.logger
+ class QuicLoggerTrace:
+ def encode_ping_frame(self) -> Dict:
+ return {"frame_type": "ping"}
+
===========changed ref 7===========
# module: aioquic.quic.logger
+ class QuicLoggerTrace:
+ def encode_stop_sending_frame(self, error_code: int, stream_id: int) -> Dict:
+ return {
+ "frame_type": "stop_sending",
+ "id": str(stream_id),
+ "error_code": error_code,
+ }
+
===========changed ref 8===========
# module: aioquic.quic.logger
+ class QuicLoggerTrace:
+ def encode_retire_connection_id_frame(self, sequence_number: int) -> Dict:
+ return {
+ "frame_type": "retire_connection_id",
+ "sequence_number": str(sequence_number),
+ }
+
===========changed ref 9===========
# module: aioquic.quic.logger
class QuicLogger:
- def encode_stop_sending_frame(self, error_code: int, stream_id: int) -> Dict:
- return {
- "frame_type": "stop_sending",
- "id": str(stream_id),
- "error_code": error_code,
- }
-
===========changed ref 10===========
# module: aioquic.quic.logger
+ class QuicLoggerTrace:
+ def encode_stream_data_blocked_frame(self, limit: int, stream_id: int) -> Dict:
+ return {
+ "frame_type": "stream_data_blocked",
+ "limit": str(limit),
+ "stream_id": str(stream_id),
+ }
+
===========changed ref 11===========
# module: aioquic.quic.logger
+ class QuicLoggerTrace:
+ def encode_padding_frame(self) -> Dict:
+ return {"frame_type": "padding"}
+
===========changed ref 12===========
# module: aioquic.quic.logger
+ class QuicLoggerTrace:
+ def encode_padding_frame(self) -> Dict:
+ return {"frame_type": "padding"}
+
===========changed ref 13===========
# module: aioquic.quic.logger
+ class QuicLoggerTrace:
+ def encode_stream_frame(self, frame: QuicStreamFrame, stream_id: int) -> Dict:
+ return {
+ "fin": frame.fin,
+ "frame_type": "stream",
+ "id": str(stream_id),
+ "length": str(len(frame.data)),
+ "offset": str(frame.offset),
+ }
+
===========changed ref 14===========
# module: aioquic.quic.logger
+ class QuicLoggerTrace:
+ def encode_path_response_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "path_response"}
+
===========changed ref 15===========
# module: aioquic.quic.logger
+ class QuicLoggerTrace:
+ def encode_path_response_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "path_response"}
+
===========changed ref 16===========
# module: aioquic.quic.logger
class QuicLogger:
- def encode_padding_frame(self) -> Dict:
- return {"frame_type": "padding"}
-
===========changed ref 17===========
# module: aioquic.quic.logger
class QuicLogger:
- def encode_retire_connection_id_frame(self, sequence_number: int) -> Dict:
- return {
- "frame_type": "retire_connection_id",
- "sequence_number": str(sequence_number),
- }
-
===========changed ref 18===========
# module: aioquic.quic.logger
+ class QuicLoggerTrace:
+ def encode_path_challenge_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "path_challenge"}
+
===========changed ref 19===========
# module: aioquic.quic.logger
+ class QuicLoggerTrace:
+ def encode_path_challenge_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "path_challenge"}
+
===========changed ref 20===========
# module: aioquic.quic.logger
class QuicLogger:
- def encode_stream_data_blocked_frame(self, limit: int, stream_id: int) -> Dict:
- return {
- "frame_type": "stream_data_blocked",
- "limit": str(limit),
- "stream_id": str(stream_id),
- }
-
===========changed ref 21===========
# module: aioquic.quic.logger
class QuicLogger:
- def encode_stream_frame(self, frame: QuicStreamFrame, stream_id: int) -> Dict:
- return {
- "fin": frame.fin,
- "frame_type": "stream",
- "id": str(stream_id),
- "length": str(len(frame.data)),
- "offset": str(frame.offset),
- }
-
===========changed ref 22===========
# module: aioquic.quic.logger
+ class QuicLoggerTrace:
+ def encode_reset_stream_frame(
+ self, error_code: int, final_size: int, stream_id: int
+ ) -> Dict:
+ return {
+ "error_code": error_code,
+ "final_size": str(final_size),
+ "frame_type": "reset_stream",
+ }
+
|
aioquic.quic.logger/QuicLogger.to_dict
|
Modified
|
aiortc~aioquic
|
6ba154bb3b33c9acb7c13f8457cb5cc1aba46c31
|
[logging] add a QuicLoggerTrace class
|
<1>:<add> Return the traces as a dictionary which can be written as JSON.
<del> Return the trace as a dictionary which can be written as JSON.
<3>:<del> traces = []
<4>:<del> if self._events:
<5>:<del> reference_time = self._events[0][0]
<6>:<del> trace = {
<7>:<del> "common_fields": {
<8>:<del> "ODCID": hexdump(self._odcid),
<9>:<del> "reference_time": "%d" % (reference_time * 1000),
<10>:<del> },
<11>:<del> "event_fields": ["relative_time", "category", "event_type", "data"],
<12>:<del> "events": list(
<13>:<del> map(
<14>:<del> lambda event: (
<15>:<del> "%d" % ((event[0] - reference_time) * 1000),
<16>:<del> event[1],
<17>:<del> event[2],
<18>:<del> event[3],
<19>:<del> ),
<20>:<del> self._events,
<21>:<del> )
<22>:<del> ),
<23>:<del> "vantage_point": self._vantage_point,
<24>:<add> return {
<add> "qlog_version": "draft-01",
<add> "traces": [trace.to_dict() for trace in self._traces],
<add> }
<del> }
<25>:<del> traces.append(trace)
<27>:<del> return {"qlog_version": "draft-01", "traces": traces}
<28>:<del>
|
# module: aioquic.quic.logger
class QuicLogger:
def to_dict(self) -> Dict[str, Any]:
<0> """
<1> Return the trace as a dictionary which can be written as JSON.
<2> """
<3> traces = []
<4> if self._events:
<5> reference_time = self._events[0][0]
<6> trace = {
<7> "common_fields": {
<8> "ODCID": hexdump(self._odcid),
<9> "reference_time": "%d" % (reference_time * 1000),
<10> },
<11> "event_fields": ["relative_time", "category", "event_type", "data"],
<12> "events": list(
<13> map(
<14> lambda event: (
<15> "%d" % ((event[0] - reference_time) * 1000),
<16> event[1],
<17> event[2],
<18> event[3],
<19> ),
<20> self._events,
<21> )
<22> ),
<23> "vantage_point": self._vantage_point,
<24> }
<25> traces.append(trace)
<26>
<27> return {"qlog_version": "draft-01", "traces": traces}
<28>
|
===========unchanged ref 0===========
at: aioquic.quic.logger
hexdump(data: bytes) -> str
at: aioquic.quic.logger.QuicLoggerTrace.__init__
self._odcid = odcid
self._events: Deque[Tuple[float, str, str, Dict[str, Any]]] = deque()
self._vantage_point = {
"name": "aioquic",
"type": "client" if is_client else "server",
}
===========changed ref 0===========
# module: aioquic.quic.logger
+ class QuicLoggerTrace:
+ def log_event(self, *, category: str, event: str, data: Dict) -> None:
+ self._events.append((time.time(), category, event, data))
+
===========changed ref 1===========
# module: aioquic.quic.logger
+ class QuicLoggerTrace:
+ def log_event(self, *, category: str, event: str, data: Dict) -> None:
+ self._events.append((time.time(), category, event, data))
+
===========changed ref 2===========
# module: aioquic.quic.logger
+ class QuicLoggerTrace:
+ def encode_streams_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "streams_blocked", "limit": str(limit)}
+
===========changed ref 3===========
# module: aioquic.quic.logger
+ class QuicLoggerTrace:
+ def encode_streams_blocked_frame(self, limit: int) -> Dict:
+ return {"frame_type": "streams_blocked", "limit": str(limit)}
+
===========changed ref 4===========
# module: aioquic.quic.logger
+ class QuicLoggerTrace:
+ def packet_type(self, packet_type: int) -> str:
+ return PACKET_TYPE_NAMES.get(packet_type & PACKET_TYPE_MASK, "1RTT")
+
===========changed ref 5===========
# module: aioquic.quic.logger
class QuicLogger:
- def encode_streams_blocked_frame(self, limit: int) -> Dict:
- return {"frame_type": "streams_blocked", "limit": str(limit)}
-
===========changed ref 6===========
# module: aioquic.quic.logger
+ class QuicLoggerTrace:
+ def encode_ping_frame(self) -> Dict:
+ return {"frame_type": "ping"}
+
===========changed ref 7===========
# module: aioquic.quic.logger
+ class QuicLoggerTrace:
+ def encode_stop_sending_frame(self, error_code: int, stream_id: int) -> Dict:
+ return {
+ "frame_type": "stop_sending",
+ "id": str(stream_id),
+ "error_code": error_code,
+ }
+
===========changed ref 8===========
# module: aioquic.quic.logger
+ class QuicLoggerTrace:
+ def encode_retire_connection_id_frame(self, sequence_number: int) -> Dict:
+ return {
+ "frame_type": "retire_connection_id",
+ "sequence_number": str(sequence_number),
+ }
+
===========changed ref 9===========
# module: aioquic.quic.logger
class QuicLogger:
- def encode_stop_sending_frame(self, error_code: int, stream_id: int) -> Dict:
- return {
- "frame_type": "stop_sending",
- "id": str(stream_id),
- "error_code": error_code,
- }
-
===========changed ref 10===========
# module: aioquic.quic.logger
+ class QuicLoggerTrace:
+ def encode_stream_data_blocked_frame(self, limit: int, stream_id: int) -> Dict:
+ return {
+ "frame_type": "stream_data_blocked",
+ "limit": str(limit),
+ "stream_id": str(stream_id),
+ }
+
===========changed ref 11===========
# module: aioquic.quic.logger
+ class QuicLoggerTrace:
+ def encode_padding_frame(self) -> Dict:
+ return {"frame_type": "padding"}
+
===========changed ref 12===========
# module: aioquic.quic.logger
+ class QuicLoggerTrace:
+ def encode_padding_frame(self) -> Dict:
+ return {"frame_type": "padding"}
+
===========changed ref 13===========
# module: aioquic.quic.logger
+ class QuicLoggerTrace:
+ def encode_stream_frame(self, frame: QuicStreamFrame, stream_id: int) -> Dict:
+ return {
+ "fin": frame.fin,
+ "frame_type": "stream",
+ "id": str(stream_id),
+ "length": str(len(frame.data)),
+ "offset": str(frame.offset),
+ }
+
===========changed ref 14===========
# module: aioquic.quic.logger
class QuicLogger:
+ def start_trace(self, is_client: bool, odcid: bytes) -> QuicLoggerTrace:
- def start_trace(self, is_client: bool, odcid: bytes) -> None:
+ trace = QuicLoggerTrace(is_client=is_client, odcid=odcid)
+ self._traces.append(trace)
+ return trace
- self._odcid = odcid
- self._vantage_point["type"] = "client" if is_client else "server"
===========changed ref 15===========
# module: aioquic.quic.logger
+ class QuicLoggerTrace:
+ def encode_path_response_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "path_response"}
+
===========changed ref 16===========
# module: aioquic.quic.logger
+ class QuicLoggerTrace:
+ def encode_path_response_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "path_response"}
+
===========changed ref 17===========
# module: aioquic.quic.logger
class QuicLogger:
- def encode_padding_frame(self) -> Dict:
- return {"frame_type": "padding"}
-
===========changed ref 18===========
# module: aioquic.quic.logger
class QuicLogger:
- def encode_retire_connection_id_frame(self, sequence_number: int) -> Dict:
- return {
- "frame_type": "retire_connection_id",
- "sequence_number": str(sequence_number),
- }
-
===========changed ref 19===========
# module: aioquic.quic.logger
+ class QuicLoggerTrace:
+ def encode_path_challenge_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "path_challenge"}
+
===========changed ref 20===========
# module: aioquic.quic.logger
+ class QuicLoggerTrace:
+ def encode_path_challenge_frame(self, data: bytes) -> Dict:
+ return {"data": hexdump(data), "frame_type": "path_challenge"}
+
===========changed ref 21===========
# module: aioquic.quic.logger
class QuicLogger:
- def encode_stream_data_blocked_frame(self, limit: int, stream_id: int) -> Dict:
- return {
- "frame_type": "stream_data_blocked",
- "limit": str(limit),
- "stream_id": str(stream_id),
- }
-
===========changed ref 22===========
# module: aioquic.quic.logger
class QuicLogger:
- def encode_stream_frame(self, frame: QuicStreamFrame, stream_id: int) -> Dict:
- return {
- "fin": frame.fin,
- "frame_type": "stream",
- "id": str(stream_id),
- "length": str(len(frame.data)),
- "offset": str(frame.offset),
- }
-
|
examples.http3_server/HttpRequestHandler.run_asgi
|
Modified
|
aiortc~aioquic
|
3ba5016acc6f9efe8754f3aabb8ee7b4278f0dbf
|
[http3 server] correctly handle `more_body` in http.response.body
|
<2>:<del> self.connection.send_data(stream_id=self.stream_id, data=b"", end_stream=True)
<3>:<del> self.transmit()
<4>:<del>
|
# module: examples.http3_server
class HttpRequestHandler:
def run_asgi(self, app: AsgiApplication) -> None:
<0> await application(self.scope, self.receive, self.send)
<1>
<2> self.connection.send_data(stream_id=self.stream_id, data=b"", end_stream=True)
<3> self.transmit()
<4>
|
===========unchanged ref 0===========
at: asyncio.queues.Queue
__class_getitem__ = classmethod(GenericAlias)
get() -> _T
at: examples.http3_server
AsgiApplication = Callable
application = getattr(module, attr_str)
at: examples.http3_server.HttpRequestHandler
send(message: Dict)
at: examples.http3_server.HttpRequestHandler.__init__
self.queue: asyncio.Queue[Dict] = asyncio.Queue()
self.scope = scope
at: typing
Dict = _alias(dict, 2, inst=False, name='Dict')
|
examples.http3_server/HttpRequestHandler.send
|
Modified
|
aiortc~aioquic
|
3ba5016acc6f9efe8754f3aabb8ee7b4278f0dbf
|
[http3 server] correctly handle `more_body` in http.response.body
|
<12>:<add> stream_id=self.stream_id,
<add> data=message.get("body", b""),
<add> end_stream=not message.get("more_body", False),
<del> stream_id=self.stream_id, data=message["body"], end_stream=False
|
# module: examples.http3_server
class HttpRequestHandler:
def send(self, message: Dict):
<0> if message["type"] == "http.response.start":
<1> self.connection.send_headers(
<2> stream_id=self.stream_id,
<3> headers=[
<4> (b":status", str(message["status"]).encode("ascii")),
<5> (b"server", b"aioquic"),
<6> (b"date", formatdate(time.time(), usegmt=True).encode()),
<7> ]
<8> + [(k, v) for k, v in message["headers"]],
<9> )
<10> elif message["type"] == "http.response.body":
<11> self.connection.send_data(
<12> stream_id=self.stream_id, data=message["body"], end_stream=False
<13> )
<14> self.transmit()
<15>
|
===========unchanged ref 0===========
at: aioquic.h0.connection.H0Connection
send_data(stream_id: int, data: bytes, end_stream: bool) -> None
at: aioquic.h3.connection.H3Connection
send_data(stream_id: int, data: bytes, end_stream: bool) -> None
at: email.utils
formatdate(timeval: Optional[float]=..., localtime: bool=..., usegmt: bool=...) -> str
at: examples.http3_server.HttpRequestHandler.__init__
self.connection = connection
self.stream_id = stream_id
self.transmit = transmit
at: time
time() -> float
at: typing.Mapping
get(key: _KT, default: Union[_VT_co, _T]) -> Union[_VT_co, _T]
get(key: _KT) -> Optional[_VT_co]
===========changed ref 0===========
# module: examples.http3_server
class HttpRequestHandler:
def run_asgi(self, app: AsgiApplication) -> None:
await application(self.scope, self.receive, self.send)
- self.connection.send_data(stream_id=self.stream_id, data=b"", end_stream=True)
- self.transmit()
-
|
examples.http3_server/HttpServerProtocol.http_event_received
|
Modified
|
aiortc~aioquic
|
a2bcfbee4c03b282d793fd0c48ec44f0ddddd288
|
[http3 server] handle request with no body correctly
|
# module: examples.http3_server
class HttpServerProtocol(QuicConnectionProtocol):
def http_event_received(self, event: HttpEvent) -> None:
<0> if isinstance(event, RequestReceived) and event.stream_id not in self._handlers:
<1> headers = []
<2> http_version = "0.9" if isinstance(self._http, H0Connection) else "3"
<3> raw_path = b""
<4> method = ""
<5> protocol = None
<6> for header, value in event.headers:
<7> if header == b":authority":
<8> headers.append((b"host", value))
<9> elif header == b":method":
<10> method = value.decode("utf8")
<11> elif header == b":path":
<12> raw_path = value
<13> elif header == b":protocol":
<14> protocol = value.decode("utf8")
<15> elif header and not header.startswith(b":"):
<16> headers.append((header, value))
<17>
<18> if b"?" in raw_path:
<19> path_bytes, query_string = raw_path.split(b"?", maxsplit=1)
<20> else:
<21> path_bytes, query_string = raw_path, b""
<22> path = path_bytes.decode("utf8")
<23>
<24> handler: Handler
<25> if method == "CONNECT" and protocol == "websocket":
<26> subprotocols: List[str] = []
<27> for header, value in event.headers:
<28> if header == b"sec-websocket-protocol":
<29> subprotocols = [
<30> x.strip() for x in value.decode("utf8").split(",")
<31> ]
<32> scope = {
<33> "headers": headers,
<34> "http_version": http_version,
<35> "method": method,
<36> "path": path,
<37> "query_string": query_string,
<38> "raw_path": raw_path,
<39> "root_path": "",
<40> "scheme": "wss",
<41> "subprotocols": subprotocols,
<42> "type": "websocket",</s>
|
===========below chunk 0===========
# module: examples.http3_server
class HttpServerProtocol(QuicConnectionProtocol):
def http_event_received(self, event: HttpEvent) -> None:
# offset: 1
handler = WebSocketHandler(
connection=self._http,
scope=scope,
stream_id=event.stream_id,
transmit=self.transmit,
)
else:
scope = {
"headers": headers,
"http_version": http_version,
"method": method,
"path": path,
"query_string": query_string,
"raw_path": raw_path,
"root_path": "",
"scheme": "https",
"type": "http",
}
handler = HttpRequestHandler(
connection=self._http,
scope=scope,
stream_id=event.stream_id,
transmit=self.transmit,
)
self._handlers[event.stream_id] = handler
asyncio.ensure_future(handler.run_asgi(application))
elif isinstance(event, DataReceived) and event.stream_id in self._handlers:
handler = self._handlers[event.stream_id]
handler.http_event_received(event)
===========unchanged ref 0===========
at: aioquic.asyncio.protocol.QuicConnectionProtocol
__init__(quic: QuicConnection, stream_handler: Optional[QuicStreamHandler]=None)
transmit() -> None
at: aioquic.h0.connection
H0Connection(quic: QuicConnection)
at: aioquic.h3.events
HttpEvent()
RequestReceived(headers: Headers, stream_id: int, stream_ended: bool)
at: examples.http3_server
HttpConnection = Union[H0Connection, H3Connection]
HttpRequestHandler(*, connection: HttpConnection, scope: Dict, stream_ended: bool, stream_id: int, transmit: Callable[[], None])
WebSocketHandler(*, connection: HttpConnection, scope: Dict, stream_id: int, transmit: Callable[[], None])
Handler = Union[HttpRequestHandler, WebSocketHandler]
at: examples.http3_server.HttpServerProtocol.quic_event_received
self._http = H3Connection(self._quic)
self._http = H0Connection(self._quic)
at: typing
List = _alias(list, 1, inst=False, name='List')
Dict = _alias(dict, 2, inst=False, name='Dict')
|
|
aioquic.quic.stream/QuicStream.on_data_delivery
|
Modified
|
aiortc~aioquic
|
51f624aaded5fcff72fcb2988058d5822810a032
|
[stream] properly transmit FIN-only stream frame
|
<17>:<add> self.send_buffer_empty = False
|
# module: aioquic.quic.stream
class QuicStream:
def on_data_delivery(
self, delivery: QuicDeliveryState, start: int, stop: int
) -> None:
<0> """
<1> Callback when sent data is ACK'd.
<2> """
<3> self.send_buffer_is_empty = False
<4> if delivery == QuicDeliveryState.ACKED:
<5> if stop > start:
<6> self._send_acked.add(start, stop)
<7> first_range = self._send_acked[0]
<8> if first_range.start == self._send_buffer_start:
<9> size = first_range.stop - first_range.start
<10> self._send_acked.shift()
<11> self._send_buffer_start += size
<12> del self._send_buffer[:size]
<13> else:
<14> if stop > start:
<15> self._send_pending.add(start, stop)
<16> if stop == self._send_buffer_fin:
<17> self._send_pending_eof = True
<18>
|
===========unchanged ref 0===========
at: aioquic.quic.packet_builder
QuicDeliveryState()
at: aioquic.quic.rangeset.RangeSet
add(start: int, stop: Optional[int]=None) -> None
shift() -> range
at: aioquic.quic.stream.QuicStream.__init__
self.send_buffer_is_empty = True
self._send_acked = RangeSet()
self._send_buffer = bytearray()
self._send_buffer_fin: Optional[int] = None
self._send_buffer_start = 0 # the offset for the start of the buffer
self._send_pending = RangeSet()
at: aioquic.quic.stream.QuicStream.get_frame
self.send_buffer_is_empty = True
at: aioquic.quic.stream.QuicStream.write
self.send_buffer_is_empty = False
self._send_buffer += data
self._send_buffer_fin = self._send_buffer_stop
|
aioquic.quic.stream/QuicStream.write
|
Modified
|
aiortc~aioquic
|
51f624aaded5fcff72fcb2988058d5822810a032
|
[stream] properly transmit FIN-only stream frame
|
<14>:<add> self.send_buffer_is_empty = False
|
# module: aioquic.quic.stream
class QuicStream:
def write(self, data: bytes, end_stream: bool = False) -> None:
<0> """
<1> Write some data bytes to the QUIC stream.
<2> """
<3> assert self._send_buffer_fin is None, "cannot call write() after FIN"
<4> size = len(data)
<5>
<6> if size:
<7> self.send_buffer_is_empty = False
<8> self._send_pending.add(
<9> self._send_buffer_stop, self._send_buffer_stop + size
<10> )
<11> self._send_buffer += data
<12> self._send_buffer_stop += size
<13> if end_stream:
<14> self._send_buffer_fin = self._send_buffer_stop
<15> self._send_pending_eof = True
<16>
|
===========unchanged ref 0===========
at: aioquic.quic.rangeset.RangeSet
add(start: int, stop: Optional[int]=None) -> None
at: aioquic.quic.stream.QuicStream.__init__
self.send_buffer_is_empty = True
self._send_buffer = bytearray()
self._send_buffer_fin: Optional[int] = None
self._send_buffer_stop = 0 # the offset for the stop of the buffer
self._send_pending = RangeSet()
at: aioquic.quic.stream.QuicStream.get_frame
self.send_buffer_is_empty = True
at: aioquic.quic.stream.QuicStream.on_data_delivery
self.send_buffer_is_empty = False
at: aioquic.quic.stream.QuicStream.write
self._send_buffer_fin = self._send_buffer_stop
===========changed ref 0===========
# module: aioquic.quic.stream
class QuicStream:
def on_data_delivery(
self, delivery: QuicDeliveryState, start: int, stop: int
) -> None:
"""
Callback when sent data is ACK'd.
"""
self.send_buffer_is_empty = False
if delivery == QuicDeliveryState.ACKED:
if stop > start:
self._send_acked.add(start, stop)
first_range = self._send_acked[0]
if first_range.start == self._send_buffer_start:
size = first_range.stop - first_range.start
self._send_acked.shift()
self._send_buffer_start += size
del self._send_buffer[:size]
else:
if stop > start:
self._send_pending.add(start, stop)
if stop == self._send_buffer_fin:
+ self.send_buffer_empty = False
self._send_pending_eof = True
|
tests.test_stream/QuicStreamTest.test_send_fin_only
|
Modified
|
aiortc~aioquic
|
51f624aaded5fcff72fcb2988058d5822810a032
|
[stream] properly transmit FIN-only stream frame
|
<3>:<add> self.assertTrue(stream.send_buffer_is_empty)
<8>:<add> self.assertFalse(stream.send_buffer_is_empty)
<14>:<add> self.assertFalse(stream.send_buffer_is_empty) # FIXME?
<16>:<add> self.assertTrue(stream.send_buffer_is_empty)
|
# module: tests.test_stream
class QuicStreamTest(TestCase):
def test_send_fin_only(self):
<0> stream = QuicStream()
<1>
<2> # nothing to send yet
<3> frame = stream.get_frame(8)
<4> self.assertIsNone(frame)
<5>
<6> # write EOF
<7> stream.write(b"", end_stream=True)
<8> frame = stream.get_frame(8)
<9> self.assertEqual(frame.data, b"")
<10> self.assertTrue(frame.fin)
<11> self.assertEqual(frame.offset, 0)
<12>
<13> # nothing more to send
<14> frame = stream.get_frame(8)
<15> self.assertIsNone(frame)
<16>
|
===========unchanged ref 0===========
at: aioquic.quic.packet.QuicStreamFrame
data: bytes = b""
fin: bool = False
offset: int = 0
at: aioquic.quic.stream
QuicStream(stream_id: Optional[int]=None, connection: Optional[Any]=None, max_stream_data_local: int=0, max_stream_data_remote: int=0)
at: aioquic.quic.stream.QuicStream
get_frame(max_size: int, max_offset: Optional[int]=None) -> Optional[QuicStreamFrame]
write(data: bytes, end_stream: bool=False) -> None
at: aioquic.quic.stream.QuicStream.__init__
self.send_buffer_is_empty = True
at: aioquic.quic.stream.QuicStream.get_frame
self.send_buffer_is_empty = True
at: aioquic.quic.stream.QuicStream.on_data_delivery
self.send_buffer_is_empty = False
at: aioquic.quic.stream.QuicStream.write
self.send_buffer_is_empty = False
at: unittest.case.TestCase
failureException: Type[BaseException]
longMessage: bool
maxDiff: Optional[int]
_testMethodName: str
_testMethodDoc: str
assertEqual(first: Any, second: Any, msg: Any=...) -> None
assertTrue(expr: Any, msg: Any=...) -> None
assertFalse(expr: Any, msg: Any=...) -> None
assertIsNone(obj: Any, msg: Any=...) -> None
===========changed ref 0===========
# module: aioquic.quic.stream
class QuicStream:
def write(self, data: bytes, end_stream: bool = False) -> None:
"""
Write some data bytes to the QUIC stream.
"""
assert self._send_buffer_fin is None, "cannot call write() after FIN"
size = len(data)
if size:
self.send_buffer_is_empty = False
self._send_pending.add(
self._send_buffer_stop, self._send_buffer_stop + size
)
self._send_buffer += data
self._send_buffer_stop += size
if end_stream:
+ self.send_buffer_is_empty = False
self._send_buffer_fin = self._send_buffer_stop
self._send_pending_eof = True
===========changed ref 1===========
# module: aioquic.quic.stream
class QuicStream:
def on_data_delivery(
self, delivery: QuicDeliveryState, start: int, stop: int
) -> None:
"""
Callback when sent data is ACK'd.
"""
self.send_buffer_is_empty = False
if delivery == QuicDeliveryState.ACKED:
if stop > start:
self._send_acked.add(start, stop)
first_range = self._send_acked[0]
if first_range.start == self._send_buffer_start:
size = first_range.stop - first_range.start
self._send_acked.shift()
self._send_buffer_start += size
del self._send_buffer[:size]
else:
if stop > start:
self._send_pending.add(start, stop)
if stop == self._send_buffer_fin:
+ self.send_buffer_empty = False
self._send_pending_eof = True
|
tests.test_stream/QuicStreamTest.test_send_fin_only_despite_blocked
|
Modified
|
aiortc~aioquic
|
51f624aaded5fcff72fcb2988058d5822810a032
|
[stream] properly transmit FIN-only stream frame
|
<3>:<add> self.assertTrue(stream.send_buffer_is_empty)
<8>:<add> self.assertFalse(stream.send_buffer_is_empty)
<14>:<add> self.assertFalse(stream.send_buffer_is_empty) # FIXME?
<16>:<add> self.assertTrue(stream.send_buffer_is_empty)
|
# module: tests.test_stream
class QuicStreamTest(TestCase):
def test_send_fin_only_despite_blocked(self):
<0> stream = QuicStream()
<1>
<2> # nothing to send yet
<3> frame = stream.get_frame(8)
<4> self.assertIsNone(frame)
<5>
<6> # write EOF
<7> stream.write(b"", end_stream=True)
<8> frame = stream.get_frame(8)
<9> self.assertEqual(frame.data, b"")
<10> self.assertTrue(frame.fin)
<11> self.assertEqual(frame.offset, 0)
<12>
<13> # nothing more to send
<14> frame = stream.get_frame(8)
<15> self.assertIsNone(frame)
<16>
|
===========unchanged ref 0===========
at: aioquic.quic.packet.QuicStreamFrame
data: bytes = b""
at: aioquic.quic.stream
QuicStream(stream_id: Optional[int]=None, connection: Optional[Any]=None, max_stream_data_local: int=0, max_stream_data_remote: int=0)
at: aioquic.quic.stream.QuicStream
get_frame(max_size: int, max_offset: Optional[int]=None) -> Optional[QuicStreamFrame]
write(data: bytes, end_stream: bool=False) -> None
at: aioquic.quic.stream.QuicStream.__init__
self.send_buffer_is_empty = True
at: aioquic.quic.stream.QuicStream.get_frame
self.send_buffer_is_empty = True
at: aioquic.quic.stream.QuicStream.on_data_delivery
self.send_buffer_is_empty = False
at: aioquic.quic.stream.QuicStream.write
self.send_buffer_is_empty = False
at: tests.test_stream.QuicStreamTest.test_send_fin_only
stream = QuicStream()
at: unittest.case.TestCase
assertEqual(first: Any, second: Any, msg: Any=...) -> None
assertTrue(expr: Any, msg: Any=...) -> None
assertFalse(expr: Any, msg: Any=...) -> None
assertIsNone(obj: Any, msg: Any=...) -> None
===========changed ref 0===========
# module: aioquic.quic.stream
class QuicStream:
def write(self, data: bytes, end_stream: bool = False) -> None:
"""
Write some data bytes to the QUIC stream.
"""
assert self._send_buffer_fin is None, "cannot call write() after FIN"
size = len(data)
if size:
self.send_buffer_is_empty = False
self._send_pending.add(
self._send_buffer_stop, self._send_buffer_stop + size
)
self._send_buffer += data
self._send_buffer_stop += size
if end_stream:
+ self.send_buffer_is_empty = False
self._send_buffer_fin = self._send_buffer_stop
self._send_pending_eof = True
===========changed ref 1===========
# module: tests.test_stream
class QuicStreamTest(TestCase):
def test_send_fin_only(self):
stream = QuicStream()
# nothing to send yet
+ self.assertTrue(stream.send_buffer_is_empty)
frame = stream.get_frame(8)
self.assertIsNone(frame)
# write EOF
stream.write(b"", end_stream=True)
+ self.assertFalse(stream.send_buffer_is_empty)
frame = stream.get_frame(8)
self.assertEqual(frame.data, b"")
self.assertTrue(frame.fin)
self.assertEqual(frame.offset, 0)
# nothing more to send
+ self.assertFalse(stream.send_buffer_is_empty) # FIXME?
frame = stream.get_frame(8)
self.assertIsNone(frame)
+ self.assertTrue(stream.send_buffer_is_empty)
===========changed ref 2===========
# module: aioquic.quic.stream
class QuicStream:
def on_data_delivery(
self, delivery: QuicDeliveryState, start: int, stop: int
) -> None:
"""
Callback when sent data is ACK'd.
"""
self.send_buffer_is_empty = False
if delivery == QuicDeliveryState.ACKED:
if stop > start:
self._send_acked.add(start, stop)
first_range = self._send_acked[0]
if first_range.start == self._send_buffer_start:
size = first_range.stop - first_range.start
self._send_acked.shift()
self._send_buffer_start += size
del self._send_buffer[:size]
else:
if stop > start:
self._send_pending.add(start, stop)
if stop == self._send_buffer_fin:
+ self.send_buffer_empty = False
self._send_pending_eof = True
|
aioquic.h3.connection/H3Connection.send_headers
|
Modified
|
aiortc~aioquic
|
fcf52613098ecbd47053e7e80e943a4b1d8a9a14
|
[http] make it possible to send headers and end stream
|
<9>:<add> :param end_stream: Whether to end the stream.
<12>:<add> self._quic.send_stream_data(
<add> stream_id, encode_frame(FrameType.HEADERS, header), end_stream
<add> )
<del> self._quic.send_stream_data(stream_id, encode_frame(FrameType.HEADERS, header))
|
# module: aioquic.h3.connection
class H3Connection:
+ def send_headers(
+ self, stream_id: int, headers: Headers, end_stream: bool = False
+ ) -> None:
- def send_headers(self, stream_id: int, headers: Headers) -> None:
<0> """
<1> Send headers on the given stream.
<2>
<3> To retrieve datagram which need to be sent over the network call the QUIC
<4> connection's :meth:`~aioquic.connection.QuicConnection.datagrams_to_send`
<5> method.
<6>
<7> :param stream_id: The stream ID on which to send the headers.
<8> :param headers: The HTTP headers to send.
<9> """
<10> encoder, header = self._encoder.encode(stream_id, 0, headers)
<11> self._quic.send_stream_data(self._local_encoder_stream_id, encoder)
<12> self._quic.send_stream_data(stream_id, encode_frame(FrameType.HEADERS, header))
<13>
|
===========unchanged ref 0===========
at: aioquic.h3.events
Headers = List[Tuple[bytes, bytes]]
|
aioquic.h0.connection/H0Connection.send_headers
|
Modified
|
aiortc~aioquic
|
fcf52613098ecbd47053e7e80e943a4b1d8a9a14
|
[http] make it possible to send headers and end stream
|
<2>:<del> self._quic.send_stream_data(
<3>:<del> stream_id,
<4>:<add> data = headers_dict[b":method"] + b" " + headers_dict[b":path"] + b"\r\n"
<del> headers_dict[b":method"] + b" " + headers_dict[b":path"] + b"\r\n",
<5>:<add> else:
<add> data = b""
<add> self._quic.send_stream_data(stream_id, data, end_stream)
<del> False,
<6>:<del> )
|
# module: aioquic.h0.connection
class H0Connection:
+ def send_headers(
+ self, stream_id: int, headers: Headers, end_stream: bool = False
+ ) -> None:
- def send_headers(self, stream_id: int, headers: List[Tuple[bytes, bytes]]) -> None:
<0> if self._is_client:
<1> headers_dict = dict(headers)
<2> self._quic.send_stream_data(
<3> stream_id,
<4> headers_dict[b":method"] + b" " + headers_dict[b":path"] + b"\r\n",
<5> False,
<6> )
<7>
|
===========unchanged ref 0===========
at: aioquic.h0.connection.H0Connection.__init__
self._quic = quic
at: aioquic.h0.connection.H0Connection.handle_event
http_events: List[HttpEvent] = []
at: aioquic.h3.events
Headers = List[Tuple[bytes, bytes]]
at: aioquic.quic.connection.QuicConnection
send_stream_data(stream_id: int, data: bytes, end_stream: bool=False) -> None
===========changed ref 0===========
# module: aioquic.h3.connection
class H3Connection:
+ def send_headers(
+ self, stream_id: int, headers: Headers, end_stream: bool = False
+ ) -> None:
- def send_headers(self, stream_id: int, headers: Headers) -> None:
"""
Send headers on the given stream.
To retrieve datagram which need to be sent over the network call the QUIC
connection's :meth:`~aioquic.connection.QuicConnection.datagrams_to_send`
method.
:param stream_id: The stream ID on which to send the headers.
:param headers: The HTTP headers to send.
+ :param end_stream: Whether to end the stream.
"""
encoder, header = self._encoder.encode(stream_id, 0, headers)
self._quic.send_stream_data(self._local_encoder_stream_id, encoder)
+ self._quic.send_stream_data(
+ stream_id, encode_frame(FrameType.HEADERS, header), end_stream
+ )
- self._quic.send_stream_data(stream_id, encode_frame(FrameType.HEADERS, header))
|
examples.http3_client/run
|
Modified
|
aiortc~aioquic
|
f5e5dd8e1102869d9f0a37b21dceecc6fbea2963
|
[http3 client] include query in path
|
<13>:<add> path = parsed.path
<add> if parsed.query:
<add> path += "?" + parsed.query
<add>
<24>:<add> parsed.netloc, path, subprotocols=["chat", "superchat"]
<del> parsed.netloc, parsed.path, subprotocols=["chat", "superchat"]
<40>:<add> http_events = await client.get(parsed.netloc, path)
<del> http_events = await client.get(parsed.netloc, parsed.path)
|
# module: examples.http3_client
def run(configuration: QuicConfiguration, url: str) -> None:
<0> # parse URL
<1> parsed = urlparse(url)
<2> assert parsed.scheme in (
<3> "https",
<4> "wss",
<5> ), "Only https:// or wss:// URLs are supported."
<6> if ":" in parsed.netloc:
<7> host, port_str = parsed.netloc.split(":")
<8> port = int(port_str)
<9> else:
<10> host = parsed.netloc
<11> port = 443
<12>
<13> async with connect(
<14> host,
<15> port,
<16> configuration=configuration,
<17> create_protocol=HttpClient,
<18> session_ticket_handler=save_session_ticket,
<19> ) as client:
<20> client = cast(HttpClient, client)
<21>
<22> if parsed.scheme == "wss":
<23> ws = await client.websocket(
<24> parsed.netloc, parsed.path, subprotocols=["chat", "superchat"]
<25> )
<26>
<27> # send some messages and receive reply
<28> for i in range(2):
<29> message = "Hello {}, WebSocket!".format(i)
<30> print("> " + message)
<31> await ws.send(message)
<32>
<33> message = await ws.recv()
<34> print("< " + message)
<35>
<36> await ws.close()
<37> else:
<38> # perform request
<39> start = time.time()
<40> http_events = await client.get(parsed.netloc, parsed.path)
<41> elapsed = time.time() - start
<42>
<43> # print speed
<44> octets = 0
<45> for http_event in http_events:
<46> if isinstance(http_event, DataReceived):
<47> octets += len(http_event.data)
<48> logger.info(
<49> "Received %d bytes in %.1f s (%.3f Mbps)"
<50> % (octets, elapsed, octets * 8 / elapsed / 1000000)
<51> )
<52>
<53> # print response
<54> </s>
|
===========below chunk 0===========
# module: examples.http3_client
def run(configuration: QuicConfiguration, url: str) -> None:
# offset: 1
if isinstance(http_event, ResponseReceived):
headers = b""
for k, v in http_event.headers:
headers += k + b": " + v + b"\r\n"
if headers:
sys.stderr.buffer.write(headers + b"\r\n")
sys.stderr.buffer.flush()
elif isinstance(http_event, DataReceived):
sys.stdout.buffer.write(http_event.data)
sys.stdout.buffer.flush()
===========unchanged ref 0===========
at: aioquic.asyncio.client
connect(host: str, port: int, *, configuration: Optional[QuicConfiguration]=None, create_protocol: Optional[Callable]=QuicConnectionProtocol, session_ticket_handler: Optional[SessionTicketHandler]=None, stream_handler: Optional[QuicStreamHandler]=None) -> AsyncGenerator[QuicConnectionProtocol, None]
connect(*args, **kwds)
at: aioquic.h3.events
DataReceived(data: bytes, stream_id: int, stream_ended: bool)
ResponseReceived(headers: Headers, stream_id: int, stream_ended: bool)
at: aioquic.quic.configuration
QuicConfiguration(alpn_protocols: Optional[List[str]]=None, certificate: Any=None, connection_id_length: int=8, idle_timeout: float=60.0, is_client: bool=True, private_key: Any=None, quic_logger: Optional[QuicLogger]=None, secrets_log_file: TextIO=None, server_name: Optional[str]=None, session_ticket: Optional[SessionTicket]=None, supported_versions: List[int]=field(
default_factory=lambda: [QuicProtocolVersion.DRAFT_22]
))
at: examples.http3_client
logger = logging.getLogger("client")
HttpClient(quic: QuicConnection, stream_handler: Optional[QuicStreamHandler]=None, /, *, quic: QuicConnection, stream_handler: Optional[QuicStreamHandler]=None)
save_session_ticket(ticket)
at: examples.http3_client.HttpClient
get(authority: str, path: str) -> Deque[HttpEvent]
websocket(authority: str, path: str, subprotocols: List[str]=[]) -> WebSocket
at: examples.http3_client.WebSocket
close(code=1000, reason="") -> None
recv() -> str
send(message: str)
===========unchanged ref 1===========
at: logging.Logger
info(msg: Any, *args: Any, exc_info: _ExcInfoType=..., stack_info: bool=..., extra: Optional[Dict[str, Any]]=..., **kwargs: Any) -> None
at: sys
stderr: TextIO
at: time
time() -> float
at: typing
cast(typ: Type[_T], val: Any) -> _T
cast(typ: str, val: Any) -> Any
cast(typ: object, val: Any) -> Any
at: typing.BinaryIO
__slots__ = ()
write(s: AnyStr) -> int
at: typing.TextIO
__slots__ = ()
at: urllib.parse
urlparse(url: str, scheme: Optional[str]=..., allow_fragments: bool=...) -> ParseResult
urlparse(url: Optional[bytes], scheme: Optional[bytes]=..., allow_fragments: bool=...) -> ParseResultBytes
|
aioquic.h3.connection/H3Connection._receive_stream_data_bidi
|
Modified
|
aiortc~aioquic
|
b9a385552d7c6a981e457075bb4be0babccc2fc9
|
[http3] start checking received frame types are valid
|
# module: aioquic.h3.connection
class H3Connection:
def _receive_stream_data_bidi(
self, stream_id: int, data: bytes, stream_ended: bool
) -> List[HttpEvent]:
<0> """
<1> Client-initiated bidirectional streams carry requests and responses.
<2> """
<3> http_events: List[HttpEvent] = []
<4>
<5> stream = self._stream[stream_id]
<6> stream.buffer += data
<7> if stream_ended:
<8> stream.ended = True
<9> if stream.blocked:
<10> return http_events
<11>
<12> # shortcut DATA frame bits
<13> if (
<14> stream.frame_size is not None
<15> and stream.frame_type == FrameType.DATA
<16> and len(stream.buffer) < stream.frame_size
<17> ):
<18> http_events.append(
<19> DataReceived(
<20> data=stream.buffer, stream_id=stream_id, stream_ended=False
<21> )
<22> )
<23> stream.frame_size -= len(stream.buffer)
<24> stream.buffer = b""
<25> return http_events
<26>
<27> # some peers (e.g. f5) end the stream with no data
<28> if stream_ended and not stream.buffer:
<29> http_events.append(
<30> DataReceived(data=b"", stream_id=stream_id, stream_ended=True)
<31> )
<32> return http_events
<33>
<34> buf = Buffer(data=stream.buffer)
<35> consumed = 0
<36>
<37> while not buf.eof():
<38> # fetch next frame header
<39> if stream.frame_size is None:
<40> try:
<41> stream.frame_type = buf.pull_uint_var()
<42> stream.frame_size = buf.pull_uint_var()
<43> except BufferReadError:
<44> break
<45> consumed = buf.tell()
<46>
<47> # check how much data is available
<48> chunk_size = min(stream.frame_size, buf.capacity - consumed</s>
|
===========below chunk 0===========
# module: aioquic.h3.connection
class H3Connection:
def _receive_stream_data_bidi(
self, stream_id: int, data: bytes, stream_ended: bool
) -> List[HttpEvent]:
# offset: 1
if (
stream.frame_type == FrameType.HEADERS
and chunk_size < stream.frame_size
):
break
# read available data
frame_data = buf.pull_bytes(chunk_size)
consumed = buf.tell()
# detect end of frame
stream.frame_size -= chunk_size
if not stream.frame_size:
stream.frame_size = None
if stream.frame_type == FrameType.DATA and (stream_ended or frame_data):
http_events.append(
DataReceived(
data=frame_data,
stream_id=stream_id,
stream_ended=stream_ended and buf.eof(),
)
)
elif stream.frame_type == FrameType.HEADERS:
try:
decoder, headers = self._decoder.feed_header(stream_id, frame_data)
except StreamBlocked:
stream.blocked = True
break
self._quic.send_stream_data(self._local_decoder_stream_id, decoder)
cls = ResponseReceived if self._is_client else RequestReceived
http_events.append(
cls(
headers=headers,
stream_id=stream_id,
stream_ended=stream_ended and buf.eof(),
)
)
# remove processed data from buffer
stream.buffer = stream.buffer[consumed:]
return http_events
===========unchanged ref 0===========
at: aioquic._buffer
BufferReadError(*args: object)
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic._buffer.Buffer
eof() -> bool
pull_uint_var() -> int
at: aioquic.h3.connection
ErrorCode(x: Union[str, bytes, bytearray], base: int)
ErrorCode(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
FrameType(x: Union[str, bytes, bytearray], base: int)
FrameType(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
Setting(x: Union[str, bytes, bytearray], base: int)
Setting(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
StreamType(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
StreamType(x: Union[str, bytes, bytearray], base: int)
encode_frame(frame_type: int, frame_data: bytes) -> bytes
encode_settings(settings: Dict[int, int]) -> bytes
parse_settings(data: bytes) -> Dict[int, int]
at: aioquic.h3.connection.H3Connection
_create_uni_stream(stream_type: int) -> int
at: aioquic.h3.connection.H3Connection.__init__
self._max_table_capacity = 0x100
self._blocked_streams = 0x10
self._quic = quic
self._encoder = Encoder()
self._stream: Dict[int, H3Stream] = {}
self._local_control_stream_id: Optional[int] = None
self._local_decoder_stream_id: Optional[int] = None
self._local_encoder_stream_id: Optional[int] = None
===========unchanged ref 1===========
at: aioquic.h3.connection.H3Stream.__init__
self.blocked = False
self.buffer = b""
self.ended = False
self.frame_size: Optional[int] = None
self.frame_type: Optional[int] = None
at: aioquic.h3.events
HttpEvent()
DataReceived(data: bytes, stream_id: int, stream_ended: bool)
at: aioquic.h3.events.DataReceived
data: bytes
stream_id: int
stream_ended: bool
at: aioquic.quic.connection
QuicConnectionError(error_code: int, frame_type: int, reason_phrase: str)
at: aioquic.quic.connection.QuicConnection
send_stream_data(stream_id: int, data: bytes, end_stream: bool=False) -> None
at: typing
List = _alias(list, 1, inst=False, name='List')
at: typing.Mapping
get(key: _KT, default: Union[_VT_co, _T]) -> Union[_VT_co, _T]
get(key: _KT) -> Optional[_VT_co]
===========changed ref 0===========
# module: aioquic.h3.connection
+ class ErrorCode(IntEnum):
+ HTTP_NO_ERROR = 0x00
+ HTTP_GENERAL_PROTOCOL_ERROR = 0x01
+ HTTP_INTERNAL_ERROR = 0x03
+ HTTP_REQUEST_CANCELLED = 0x05
+ HTTP_INCOMPLETE_REQUEST = 0x06
+ HTTP_CONNECT_ERROR = 0x07
+ HTTP_EXCESSIVE_LOAD = 0x08
+ HTTP_VERSION_FALLBACK = 0x09
+ HTTP_WRONG_STREAM = 0x0A
+ HTTP_ID_ERROR = 0x0B
+ HTTP_STREAM_CREATION_ERROR = 0x0D
+ HTTP_CLOSED_CRITICAL_STREAM = 0x0F
+ HTTP_EARLY_RESPONSE = 0x11
+ HTTP_MISSING_SETTINGS = 0x12
+ HTTP_UNEXPECTED_FRAME = 0x13
+ HTTP_REQUEST_REJECTED = 0x14
+ HTTP_SETTINGS_ERROR = 0xFF
+
===========changed ref 1===========
# module: aioquic.h3.connection
class H3Connection:
+ def _handle_control_frame(self, frame_type: int, frame_data: bytes) -> None:
+ """
+ Handle a frame received on the peer's control stream.
+ """
+ if frame_type == FrameType.SETTINGS:
+ settings = parse_settings(frame_data)
+ encoder = self._encoder.apply_settings(
+ max_table_capacity=settings.get(Setting.QPACK_MAX_TABLE_CAPACITY, 0),
+ blocked_streams=settings.get(Setting.QPACK_BLOCKED_STREAMS, 0),
+ )
+ self._quic.send_stream_data(self._local_encoder_stream_id, encoder)
+ elif frame_type in (
+ FrameType.DATA,
+ FrameType.HEADERS,
+ FrameType.PUSH_PROMISE,
+ FrameType.DUPLICATE_PUSH,
+ ):
+ raise QuicConnectionError(
+ error_code=ErrorCode.HTTP_WRONG_STREAM,
+ frame_type=None,
+ reason_phrase="Invalid frame type on control stream",
+ )
+
|
|
aioquic.h3.connection/H3Connection._receive_stream_data_uni
|
Modified
|
aiortc~aioquic
|
b9a385552d7c6a981e457075bb4be0babccc2fc9
|
[http3] start checking received frame types are valid
|
<38>:<del> # unidirectional control stream
<39>:<del> if frame_type == FrameType.SETTINGS:
<40>:<del> settings = parse_settings(frame_data)
<41>:<del> encoder = self._encoder.apply_settings(
<42>:<del> max_table_capacity=settings
|
# module: aioquic.h3.connection
class H3Connection:
def _receive_stream_data_uni(self, stream_id: int, data: bytes) -> List[HttpEvent]:
<0> http_events: List[HttpEvent] = []
<1>
<2> stream = self._stream[stream_id]
<3> stream.buffer += data
<4>
<5> buf = Buffer(data=stream.buffer)
<6> consumed = 0
<7> unblocked_streams: Set[int] = set()
<8>
<9> while not buf.eof():
<10> # fetch stream type for unidirectional streams
<11> if stream.stream_type is None:
<12> try:
<13> stream.stream_type = buf.pull_uint_var()
<14> except BufferReadError:
<15> break
<16> consumed = buf.tell()
<17>
<18> if stream.stream_type == StreamType.CONTROL:
<19> assert self._peer_control_stream_id is None
<20> self._peer_control_stream_id = stream_id
<21> elif stream.stream_type == StreamType.QPACK_DECODER:
<22> assert self._peer_decoder_stream_id is None
<23> self._peer_decoder_stream_id = stream_id
<24> elif stream.stream_type == StreamType.QPACK_ENCODER:
<25> assert self._peer_encoder_stream_id is None
<26> self._peer_encoder_stream_id = stream_id
<27>
<28> if stream_id == self._peer_control_stream_id:
<29> # fetch next frame
<30> try:
<31> frame_type = buf.pull_uint_var()
<32> frame_length = buf.pull_uint_var()
<33> frame_data = buf.pull_bytes(frame_length)
<34> except BufferReadError:
<35> break
<36> consumed = buf.tell()
<37>
<38> # unidirectional control stream
<39> if frame_type == FrameType.SETTINGS:
<40> settings = parse_settings(frame_data)
<41> encoder = self._encoder.apply_settings(
<42> max_table_capacity=settings</s>
|
===========below chunk 0===========
# module: aioquic.h3.connection
class H3Connection:
def _receive_stream_data_uni(self, stream_id: int, data: bytes) -> List[HttpEvent]:
# offset: 1
Setting.QPACK_MAX_TABLE_CAPACITY, 0
),
blocked_streams=settings.get(Setting.QPACK_BLOCKED_STREAMS, 0),
)
self._quic.send_stream_data(self._local_encoder_stream_id, encoder)
else:
# fetch unframed data
data = buf.pull_bytes(buf.capacity - buf.tell())
consumed = buf.tell()
if stream_id == self._peer_decoder_stream_id:
self._encoder.feed_decoder(data)
elif stream_id == self._peer_encoder_stream_id:
unblocked_streams.update(self._decoder.feed_encoder(data))
# remove processed data from buffer
stream.buffer = stream.buffer[consumed:]
# process unblocked streams
for stream_id in unblocked_streams:
stream = self._stream[stream_id]
decoder, headers = self._decoder.resume_header(stream_id)
stream.blocked = False
cls = ResponseReceived if self._is_client else RequestReceived
http_events.append(
cls(
headers=headers,
stream_id=stream_id,
stream_ended=stream.ended and not stream.buffer,
)
)
http_events.extend(
self._receive_stream_data_bidi(stream_id, b"", stream.ended)
)
return http_events
===========unchanged ref 0===========
at: aioquic._buffer
BufferReadError(*args: object)
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic._buffer.Buffer
eof() -> bool
tell() -> int
pull_bytes(length: int) -> bytes
pull_uint_var() -> int
at: aioquic.h3.connection
ErrorCode(x: Union[str, bytes, bytearray], base: int)
ErrorCode(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
FrameType(x: Union[str, bytes, bytearray], base: int)
FrameType(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
StreamType(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
StreamType(x: Union[str, bytes, bytearray], base: int)
at: aioquic.h3.connection.H3Connection.__init__
self._is_client = quic.configuration.is_client
self._quic = quic
self._decoder = Decoder(self._max_table_capacity, self._blocked_streams)
self._stream: Dict[int, H3Stream] = {}
self._local_decoder_stream_id: Optional[int] = None
self._peer_control_stream_id: Optional[int] = None
at: aioquic.h3.connection.H3Connection._init_connection
self._local_decoder_stream_id = self._create_uni_stream(
StreamType.QPACK_DECODER
)
at: aioquic.h3.connection.H3Connection._receive_stream_data_bidi
http_events: List[HttpEvent] = []
stream = self._stream[stream_id]
buf = Buffer(data=stream.buffer)
at: aioquic.h3.connection.H3Stream.__init__
self.frame_size: Optional[int] = None
===========unchanged ref 1===========
self.frame_type: Optional[int] = None
at: aioquic.h3.events
HttpEvent()
DataReceived(data: bytes, stream_id: int, stream_ended: bool)
RequestReceived(headers: Headers, stream_id: int, stream_ended: bool)
ResponseReceived(headers: Headers, stream_id: int, stream_ended: bool)
at: aioquic.h3.events.RequestReceived
headers: Headers
stream_id: int
stream_ended: bool
at: aioquic.h3.events.ResponseReceived
headers: Headers
stream_id: int
stream_ended: bool
at: aioquic.quic.connection
QuicConnectionError(error_code: int, frame_type: int, reason_phrase: str)
at: aioquic.quic.connection.QuicConnection
send_stream_data(stream_id: int, data: bytes, end_stream: bool=False) -> None
at: typing
List = _alias(list, 1, inst=False, name='List')
Set = _alias(set, 1, inst=False, name='Set')
===========changed ref 0===========
# module: aioquic.h3.connection
+ class ErrorCode(IntEnum):
+ HTTP_NO_ERROR = 0x00
+ HTTP_GENERAL_PROTOCOL_ERROR = 0x01
+ HTTP_INTERNAL_ERROR = 0x03
+ HTTP_REQUEST_CANCELLED = 0x05
+ HTTP_INCOMPLETE_REQUEST = 0x06
+ HTTP_CONNECT_ERROR = 0x07
+ HTTP_EXCESSIVE_LOAD = 0x08
+ HTTP_VERSION_FALLBACK = 0x09
+ HTTP_WRONG_STREAM = 0x0A
+ HTTP_ID_ERROR = 0x0B
+ HTTP_STREAM_CREATION_ERROR = 0x0D
+ HTTP_CLOSED_CRITICAL_STREAM = 0x0F
+ HTTP_EARLY_RESPONSE = 0x11
+ HTTP_MISSING_SETTINGS = 0x12
+ HTTP_UNEXPECTED_FRAME = 0x13
+ HTTP_REQUEST_REJECTED = 0x14
+ HTTP_SETTINGS_ERROR = 0xFF
+
===========changed ref 1===========
# module: aioquic.h3.connection
class H3Connection:
+ def _handle_control_frame(self, frame_type: int, frame_data: bytes) -> None:
+ """
+ Handle a frame received on the peer's control stream.
+ """
+ if frame_type == FrameType.SETTINGS:
+ settings = parse_settings(frame_data)
+ encoder = self._encoder.apply_settings(
+ max_table_capacity=settings.get(Setting.QPACK_MAX_TABLE_CAPACITY, 0),
+ blocked_streams=settings.get(Setting.QPACK_BLOCKED_STREAMS, 0),
+ )
+ self._quic.send_stream_data(self._local_encoder_stream_id, encoder)
+ elif frame_type in (
+ FrameType.DATA,
+ FrameType.HEADERS,
+ FrameType.PUSH_PROMISE,
+ FrameType.DUPLICATE_PUSH,
+ ):
+ raise QuicConnectionError(
+ error_code=ErrorCode.HTTP_WRONG_STREAM,
+ frame_type=None,
+ reason_phrase="Invalid frame type on control stream",
+ )
+
|
aioquic.h3.connection/H3Connection.send_headers
|
Modified
|
aiortc~aioquic
|
2af0111d1a4ee3037b1500a2f8004e559aea97c6
|
[http3] add _decode_headers and _encode_headers helpers
|
<11>:<add> frame_data = self._encode_headers(stream_id, headers)
<del> encoder, header = self._encoder.encode(stream_id, 0, headers)
<12>:<del> self._quic.send_stream_data(self._local_encoder_stream_id, encoder)
<14>:<add> stream_id, encode_frame(FrameType.HEADERS, frame_data), end_stream
<del> stream_id, encode_frame(FrameType.HEADERS, header), end_stream
|
# module: aioquic.h3.connection
class H3Connection:
def send_headers(
self, stream_id: int, headers: Headers, end_stream: bool = False
) -> None:
<0> """
<1> Send headers on the given stream.
<2>
<3> To retrieve datagram which need to be sent over the network call the QUIC
<4> connection's :meth:`~aioquic.connection.QuicConnection.datagrams_to_send`
<5> method.
<6>
<7> :param stream_id: The stream ID on which to send the headers.
<8> :param headers: The HTTP headers to send.
<9> :param end_stream: Whether to end the stream.
<10> """
<11> encoder, header = self._encoder.encode(stream_id, 0, headers)
<12> self._quic.send_stream_data(self._local_encoder_stream_id, encoder)
<13> self._quic.send_stream_data(
<14> stream_id, encode_frame(FrameType.HEADERS, header), end_stream
<15> )
<16>
|
===========unchanged ref 0===========
at: aioquic.h3.connection
FrameType(x: Union[str, bytes, bytearray], base: int)
FrameType(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
encode_frame(frame_type: int, frame_data: bytes) -> bytes
at: aioquic.h3.connection.H3Connection
_encode_headers(stream_id, headers: Headers) -> bytes
at: aioquic.h3.connection.H3Connection.__init__
self._quic = quic
at: aioquic.h3.events
Headers = List[Tuple[bytes, bytes]]
at: aioquic.quic.connection.QuicConnection
send_stream_data(stream_id: int, data: bytes, end_stream: bool=False) -> None
|
aioquic.h3.connection/H3Connection._receive_stream_data_bidi
|
Modified
|
aiortc~aioquic
|
2af0111d1a4ee3037b1500a2f8004e559aea97c6
|
[http3] add _decode_headers and _encode_headers helpers
|
# module: aioquic.h3.connection
class H3Connection:
def _receive_stream_data_bidi(
self, stream_id: int, data: bytes, stream_ended: bool
) -> List[HttpEvent]:
<0> """
<1> Client-initiated bidirectional streams carry requests and responses.
<2> """
<3> http_events: List[HttpEvent] = []
<4>
<5> stream = self._stream[stream_id]
<6> stream.buffer += data
<7> if stream_ended:
<8> stream.ended = True
<9> if stream.blocked:
<10> return http_events
<11>
<12> # shortcut DATA frame bits
<13> if (
<14> stream.frame_size is not None
<15> and stream.frame_type == FrameType.DATA
<16> and len(stream.buffer) < stream.frame_size
<17> ):
<18> http_events.append(
<19> DataReceived(
<20> data=stream.buffer, stream_id=stream_id, stream_ended=False
<21> )
<22> )
<23> stream.frame_size -= len(stream.buffer)
<24> stream.buffer = b""
<25> return http_events
<26>
<27> # some peers (e.g. f5) end the stream with no data
<28> if stream_ended and not stream.buffer:
<29> http_events.append(
<30> DataReceived(data=b"", stream_id=stream_id, stream_ended=True)
<31> )
<32> return http_events
<33>
<34> buf = Buffer(data=stream.buffer)
<35> consumed = 0
<36>
<37> while not buf.eof():
<38> # fetch next frame header
<39> if stream.frame_size is None:
<40> try:
<41> stream.frame_type = buf.pull_uint_var()
<42> stream.frame_size = buf.pull_uint_var()
<43> except BufferReadError:
<44> break
<45> consumed = buf.tell()
<46>
<47> # check how much data is available
<48> chunk_size = min(stream.frame_size, buf.capacity - consumed</s>
|
===========below chunk 0===========
# module: aioquic.h3.connection
class H3Connection:
def _receive_stream_data_bidi(
self, stream_id: int, data: bytes, stream_ended: bool
) -> List[HttpEvent]:
# offset: 1
if (
stream.frame_type == FrameType.HEADERS
and chunk_size < stream.frame_size
):
break
# read available data
frame_data = buf.pull_bytes(chunk_size)
consumed = buf.tell()
# detect end of frame
stream.frame_size -= chunk_size
if not stream.frame_size:
stream.frame_size = None
if stream.frame_type == FrameType.DATA and (stream_ended or frame_data):
http_events.append(
DataReceived(
data=frame_data,
stream_id=stream_id,
stream_ended=stream_ended and buf.eof(),
)
)
elif stream.frame_type == FrameType.HEADERS:
try:
decoder, headers = self._decoder.feed_header(stream_id, frame_data)
except StreamBlocked:
stream.blocked = True
break
self._quic.send_stream_data(self._local_decoder_stream_id, decoder)
cls = ResponseReceived if self._is_client else RequestReceived
http_events.append(
cls(
headers=headers,
stream_id=stream_id,
stream_ended=stream_ended and buf.eof(),
)
)
elif stream.frame_type in (
FrameType.PRIORITY,
FrameType.CANCEL_PUSH,
FrameType.SETTINGS,
FrameType.GOAWAY,
FrameType.MAX_PUSH_ID,
):
raise QuicConnectionError(
error_code=ErrorCode.HTTP_WRONG_STREAM,
frame_type=None,
reason_phrase="Invalid frame type on request stream",
)
# remove processed data from buffer
stream.buffer = stream.buffer[consumed:]</s>
===========below chunk 1===========
# module: aioquic.h3.connection
class H3Connection:
def _receive_stream_data_bidi(
self, stream_id: int, data: bytes, stream_ended: bool
) -> List[HttpEvent]:
# offset: 2
<s> frame type on request stream",
)
# remove processed data from buffer
stream.buffer = stream.buffer[consumed:]
return http_events
===========unchanged ref 0===========
at: aioquic._buffer
BufferReadError(*args: object)
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic._buffer.Buffer
eof() -> bool
tell() -> int
pull_bytes(length: int) -> bytes
pull_uint_var() -> int
at: aioquic.h3.connection
FrameType(x: Union[str, bytes, bytearray], base: int)
FrameType(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
Setting(x: Union[str, bytes, bytearray], base: int)
Setting(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
StreamType(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
StreamType(x: Union[str, bytes, bytearray], base: int)
at: aioquic.h3.connection.H3Connection
_create_uni_stream(stream_type: int) -> int
_decode_headers(stream_id: int, frame_data: bytes) -> Headers
at: aioquic.h3.connection.H3Connection.__init__
self._max_table_capacity = 0x100
self._blocked_streams = 0x10
self._is_client = quic.configuration.is_client
self._stream: Dict[int, H3Stream] = {}
self._local_decoder_stream_id: Optional[int] = None
self._local_encoder_stream_id: Optional[int] = None
at: aioquic.h3.connection.H3Stream.__init__
self.blocked = False
self.buffer = b""
self.ended = False
self.frame_size: Optional[int] = None
self.frame_type: Optional[int] = None
at: aioquic.h3.events
HttpEvent()
===========unchanged ref 1===========
DataReceived(data: bytes, stream_id: int, stream_ended: bool)
RequestReceived(headers: Headers, stream_id: int, stream_ended: bool)
ResponseReceived(headers: Headers, stream_id: int, stream_ended: bool)
at: aioquic.h3.events.DataReceived
data: bytes
stream_id: int
stream_ended: bool
at: aioquic.h3.events.RequestReceived
headers: Headers
stream_id: int
stream_ended: bool
at: aioquic.h3.events.ResponseReceived
headers: Headers
stream_id: int
stream_ended: bool
at: typing
List = _alias(list, 1, inst=False, name='List')
===========changed ref 0===========
# module: aioquic.h3.connection
class H3Connection:
+ def _decode_headers(self, stream_id: int, frame_data: bytes) -> Headers:
+ """
+ Decode a HEADERS block and send decoder updates on the decoder stream.
+ """
+ decoder, headers = self._decoder.feed_header(stream_id, frame_data)
+ self._quic.send_stream_data(self._local_decoder_stream_id, decoder)
+ return headers
+
===========changed ref 1===========
# module: aioquic.h3.connection
class H3Connection:
+ def _encode_headers(self, stream_id, headers: Headers) -> bytes:
+ """
+ Encode a HEADERS block and send encoder updates on the encoder stream.
+ """
+ encoder, frame_data = self._encoder.encode(stream_id, 0, headers)
+ self._quic.send_stream_data(self._local_encoder_stream_id, encoder)
+ return frame_data
+
===========changed ref 2===========
# module: aioquic.h3.connection
class H3Connection:
def send_headers(
self, stream_id: int, headers: Headers, end_stream: bool = False
) -> None:
"""
Send headers on the given stream.
To retrieve datagram which need to be sent over the network call the QUIC
connection's :meth:`~aioquic.connection.QuicConnection.datagrams_to_send`
method.
:param stream_id: The stream ID on which to send the headers.
:param headers: The HTTP headers to send.
:param end_stream: Whether to end the stream.
"""
+ frame_data = self._encode_headers(stream_id, headers)
- encoder, header = self._encoder.encode(stream_id, 0, headers)
- self._quic.send_stream_data(self._local_encoder_stream_id, encoder)
self._quic.send_stream_data(
+ stream_id, encode_frame(FrameType.HEADERS, frame_data), end_stream
- stream_id, encode_frame(FrameType.HEADERS, header), end_stream
)
|
|
aioquic.h3.connection/H3Stream.__init__
|
Modified
|
aiortc~aioquic
|
eb4fc3878387177cf3b52a94f4c63fb9c871cbcf
|
[http3] add initial support for server push
|
<5>:<add> self.push_id: Optional[int] = None
|
# module: aioquic.h3.connection
class H3Stream:
def __init__(self) -> None:
<0> self.blocked = False
<1> self.buffer = b""
<2> self.ended = False
<3> self.frame_size: Optional[int] = None
<4> self.frame_type: Optional[int] = None
<5> self.stream_type: Optional[int] = None
<6>
|
===========unchanged ref 0===========
at: aioquic._buffer.Buffer
eof() -> bool
pull_uint_var() -> int
at: aioquic.h3.connection.parse_settings
buf = Buffer(data=data)
settings = []
===========changed ref 0===========
# module: aioquic.h3.connection
+ def parse_max_push_id(data: bytes) -> int:
+ buf = Buffer(data=data)
+ max_push_id = buf.pull_uint_var()
+ assert buf.eof()
+ return max_push_id
+
===========changed ref 1===========
# module: aioquic.h3.events
+ @dataclass
+ class PushPromiseReceived(HttpEvent):
+ """
+ The PushedStreamReceived event is fired whenever a pushed stream has been
+ received from the remote peer.
+ """
+
+ headers: Headers
+ "The request headers."
+
+ push_id: int
+ "The Push ID of the push promise."
+
+ stream_id: int
+ "The Stream ID of the stream that the push is related to."
+
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.