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.tls/push_opaque
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<4>:<add> buf.push_bytes(value)
<del> push_bytes(buf, value)
|
# module: aioquic.tls
def push_opaque(buf: Buffer, capacity: int, value: bytes) -> None:
<0> """
<1> Push an opaque value prefix by a length.
<2> """
<3> with push_block(buf, capacity):
<4> push_bytes(buf, value)
<5>
|
===========unchanged ref 0===========
at: aioquic.tls
Group(x: Union[str, bytes, bytearray], base: int)
Group(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
at: typing
Tuple = _TupleType(tuple, -1, inst=False, name='Tuple')
===========changed ref 0===========
# module: aioquic.tls
def pull_opaque(buf: Buffer, capacity: int) -> bytes:
"""
Pull an opaque value prefixed by a length.
"""
with pull_block(buf, capacity) as length:
+ return buf.pull_bytes(length)
- return pull_bytes(buf, length)
===========changed ref 1===========
# module: aioquic.tls
def push_list(
+ buf: Buffer, capacity: int, func: Callable[[T], None], values: Sequence[T]
- buf: Buffer, capacity: int, func: Callable[[Buffer, T], None], values: Sequence[T]
) -> None:
"""
Push a list of items.
"""
with push_block(buf, capacity):
for value in values:
+ func(value)
- func(buf, value)
===========changed ref 2===========
# module: aioquic.tls
def pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm:
+ return SignatureAlgorithm(buf.pull_uint16())
- return SignatureAlgorithm(pull_uint16(buf))
===========changed ref 3===========
# module: aioquic.tls
def pull_group(buf: Buffer) -> Group:
+ return Group(buf.pull_uint16())
- return Group(pull_uint16(buf))
===========changed ref 4===========
# module: aioquic.tls
def pull_key_exchange_mode(buf: Buffer) -> KeyExchangeMode:
+ return KeyExchangeMode(buf.pull_uint8())
- return KeyExchangeMode(pull_uint8(buf))
===========changed ref 5===========
# module: aioquic.tls
def pull_compression_method(buf: Buffer) -> CompressionMethod:
+ return CompressionMethod(buf.pull_uint8())
- return CompressionMethod(pull_uint8(buf))
===========changed ref 6===========
# module: aioquic.tls
# INTEGERS
def pull_cipher_suite(buf: Buffer) -> CipherSuite:
+ return CipherSuite(buf.pull_uint16())
- return CipherSuite(pull_uint16(buf))
===========changed ref 7===========
# module: aioquic.tls
# LISTS
+ def pull_list(buf: Buffer, capacity: int, func: Callable[[], T]) -> List[T]:
- def pull_list(buf: Buffer, capacity: int, func: Callable[[Buffer], T]) -> List[T]:
"""
Pull a list of items.
"""
items = []
with pull_block(buf, capacity) as length:
+ end = buf.tell() + length
- end = buf._pos + length
+ while buf.tell() < end:
- while buf._pos < end:
+ items.append(func())
- items.append(func(buf))
return items
===========changed ref 8===========
# module: aioquic.tls
- push_cipher_suite = push_uint16
- push_compression_method = push_uint8
- push_group = push_uint16
- push_key_exchange_mode = push_uint8
- push_signature_algorithm = push_uint16
-
===========changed ref 9===========
# module: aioquic.tls
# BLOCKS
@contextmanager
def pull_block(buf: Buffer, capacity: int) -> Generator:
length = 0
+ for b in buf.pull_bytes(capacity):
- for b in pull_bytes(buf, capacity):
length = (length << 8) | b
+ end = buf.tell() + length
- end = buf._pos + length
yield length
+ assert buf.tell() == end
- assert buf._pos == end
===========changed ref 10===========
# module: aioquic.tls
@contextmanager
def push_block(buf: Buffer, capacity: int) -> Generator:
"""
Context manager to push a variable-length block, with `capacity` bytes
to write the length.
"""
+ start = buf.tell() + capacity
+ buf.seek(start)
- buf._pos += capacity
- start = buf._pos
yield
+ end = buf.tell()
+ length = end - start
- length = buf._pos - start
while capacity:
+ buf.seek(start - capacity)
+ buf.push_uint8((length >> (8 * (capacity - 1))) & 0xFF)
- buf._data[start - capacity] = (length >> (8 * (capacity - 1))) & 0xFF
capacity -= 1
+ buf.seek(end)
===========changed ref 11===========
# 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")
-
===========changed ref 12===========
# module: aioquic.buffer
class Buffer:
+ def push_uint8(self, v: int) -> None:
+ """
+ Push an 8-bit unsigned integer.
+ """
+ self._data[self._pos] = v
+ self._pos += 1
+
===========changed ref 13===========
# module: aioquic.buffer
- def push_uint8(buf: Buffer, v: int) -> None:
- """
- Push an 8-bit unsigned integer.
- """
- buf._data[buf._pos] = v
- buf._pos += 1
-
===========changed ref 14===========
# module: aioquic.buffer
class Buffer:
+ def push_uint64(self, v: int) -> None:
+ """
+ Push a 64-bit unsigned integer.
+ """
+ pack_into("!Q", self._data, self._pos, v)
+ self._pos += 8
+
===========changed ref 15===========
# module: aioquic.buffer
class Buffer:
+ def push_uint32(self, v: int) -> None:
+ """
+ Push a 32-bit unsigned integer.
+ """
+ pack_into("!L", self._data, self._pos, v)
+ self._pos += 4
+
===========changed ref 16===========
# module: aioquic.buffer
class Buffer:
+ def push_uint16(self, v: int) -> None:
+ """
+ Push a 16-bit unsigned integer.
+ """
+ pack_into("!H", self._data, self._pos, v)
+ self._pos += 2
+
===========changed ref 17===========
# module: aioquic.buffer
- def push_uint64(buf: Buffer, v: int) -> None:
- """
- Push a 64-bit unsigned integer.
- """
- pack_into("!Q", buf._data, buf._pos, v)
- buf._pos += 8
-
===========changed ref 18===========
# module: aioquic.buffer
- def push_uint32(buf: Buffer, v: int) -> None:
- """
- Push a 32-bit unsigned integer.
- """
- pack_into("!L", buf._data, buf._pos, v)
- buf._pos += 4
-
===========changed ref 19===========
# module: aioquic.buffer
- def push_uint16(buf: Buffer, v: int) -> None:
- """
- Push a 16-bit unsigned integer.
- """
- pack_into("!H", buf._data, buf._pos, v)
- buf._pos += 2
-
===========changed ref 20===========
# module: aioquic.buffer
class Buffer:
+ def pull_uint8(self) -> int:
+ """
+ Pull an 8-bit unsigned integer.
+ """
+ try:
+ v = self._data[self._pos]
+ self._pos += 1
+ return v
+ except IndexError:
+ raise BufferReadError
+
|
aioquic.tls/push_extension
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<0>:<add> buf.push_uint16(extension_type)
<del> push_uint16(buf, extension_type)
|
# module: aioquic.tls
@contextmanager
def push_extension(buf: Buffer, extension_type: int) -> Generator:
<0> push_uint16(buf, extension_type)
<1> with push_block(buf, 2):
<2> yield
<3>
|
===========unchanged ref 0===========
at: aioquic.buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic.tls
pull_group(buf: Buffer) -> Group
pull_opaque(buf: Buffer, capacity: int) -> bytes
KeyShareEntry = Tuple[Group, bytes]
===========changed ref 0===========
# module: aioquic.tls
def pull_opaque(buf: Buffer, capacity: int) -> bytes:
"""
Pull an opaque value prefixed by a length.
"""
with pull_block(buf, capacity) as length:
+ return buf.pull_bytes(length)
- return pull_bytes(buf, length)
===========changed ref 1===========
# module: aioquic.tls
def pull_group(buf: Buffer) -> Group:
+ return Group(buf.pull_uint16())
- return Group(pull_uint16(buf))
===========changed ref 2===========
# module: aioquic.tls
def push_opaque(buf: Buffer, capacity: int, value: bytes) -> None:
"""
Push an opaque value prefix by a length.
"""
with push_block(buf, capacity):
+ buf.push_bytes(value)
- push_bytes(buf, value)
===========changed ref 3===========
# module: aioquic.tls
def push_list(
+ buf: Buffer, capacity: int, func: Callable[[T], None], values: Sequence[T]
- buf: Buffer, capacity: int, func: Callable[[Buffer, T], None], values: Sequence[T]
) -> None:
"""
Push a list of items.
"""
with push_block(buf, capacity):
for value in values:
+ func(value)
- func(buf, value)
===========changed ref 4===========
# module: aioquic.tls
def pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm:
+ return SignatureAlgorithm(buf.pull_uint16())
- return SignatureAlgorithm(pull_uint16(buf))
===========changed ref 5===========
# module: aioquic.tls
def pull_key_exchange_mode(buf: Buffer) -> KeyExchangeMode:
+ return KeyExchangeMode(buf.pull_uint8())
- return KeyExchangeMode(pull_uint8(buf))
===========changed ref 6===========
# module: aioquic.tls
def pull_compression_method(buf: Buffer) -> CompressionMethod:
+ return CompressionMethod(buf.pull_uint8())
- return CompressionMethod(pull_uint8(buf))
===========changed ref 7===========
# module: aioquic.tls
# INTEGERS
def pull_cipher_suite(buf: Buffer) -> CipherSuite:
+ return CipherSuite(buf.pull_uint16())
- return CipherSuite(pull_uint16(buf))
===========changed ref 8===========
# module: aioquic.tls
# LISTS
+ def pull_list(buf: Buffer, capacity: int, func: Callable[[], T]) -> List[T]:
- def pull_list(buf: Buffer, capacity: int, func: Callable[[Buffer], T]) -> List[T]:
"""
Pull a list of items.
"""
items = []
with pull_block(buf, capacity) as length:
+ end = buf.tell() + length
- end = buf._pos + length
+ while buf.tell() < end:
- while buf._pos < end:
+ items.append(func())
- items.append(func(buf))
return items
===========changed ref 9===========
# module: aioquic.tls
- push_cipher_suite = push_uint16
- push_compression_method = push_uint8
- push_group = push_uint16
- push_key_exchange_mode = push_uint8
- push_signature_algorithm = push_uint16
-
===========changed ref 10===========
# module: aioquic.tls
# BLOCKS
@contextmanager
def pull_block(buf: Buffer, capacity: int) -> Generator:
length = 0
+ for b in buf.pull_bytes(capacity):
- for b in pull_bytes(buf, capacity):
length = (length << 8) | b
+ end = buf.tell() + length
- end = buf._pos + length
yield length
+ assert buf.tell() == end
- assert buf._pos == end
===========changed ref 11===========
# module: aioquic.tls
@contextmanager
def push_block(buf: Buffer, capacity: int) -> Generator:
"""
Context manager to push a variable-length block, with `capacity` bytes
to write the length.
"""
+ start = buf.tell() + capacity
+ buf.seek(start)
- buf._pos += capacity
- start = buf._pos
yield
+ end = buf.tell()
+ length = end - start
- length = buf._pos - start
while capacity:
+ buf.seek(start - capacity)
+ buf.push_uint8((length >> (8 * (capacity - 1))) & 0xFF)
- buf._data[start - capacity] = (length >> (8 * (capacity - 1))) & 0xFF
capacity -= 1
+ buf.seek(end)
===========changed ref 12===========
# 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")
-
===========changed ref 13===========
# module: aioquic.buffer
class Buffer:
+ def push_uint8(self, v: int) -> None:
+ """
+ Push an 8-bit unsigned integer.
+ """
+ self._data[self._pos] = v
+ self._pos += 1
+
===========changed ref 14===========
# module: aioquic.buffer
- def push_uint8(buf: Buffer, v: int) -> None:
- """
- Push an 8-bit unsigned integer.
- """
- buf._data[buf._pos] = v
- buf._pos += 1
-
===========changed ref 15===========
# module: aioquic.buffer
class Buffer:
+ def push_uint64(self, v: int) -> None:
+ """
+ Push a 64-bit unsigned integer.
+ """
+ pack_into("!Q", self._data, self._pos, v)
+ self._pos += 8
+
===========changed ref 16===========
# module: aioquic.buffer
class Buffer:
+ def push_uint32(self, v: int) -> None:
+ """
+ Push a 32-bit unsigned integer.
+ """
+ pack_into("!L", self._data, self._pos, v)
+ self._pos += 4
+
===========changed ref 17===========
# module: aioquic.buffer
class Buffer:
+ def push_uint16(self, v: int) -> None:
+ """
+ Push a 16-bit unsigned integer.
+ """
+ pack_into("!H", self._data, self._pos, v)
+ self._pos += 2
+
===========changed ref 18===========
# module: aioquic.buffer
- def push_uint64(buf: Buffer, v: int) -> None:
- """
- Push a 64-bit unsigned integer.
- """
- pack_into("!Q", buf._data, buf._pos, v)
- buf._pos += 8
-
===========changed ref 19===========
# module: aioquic.buffer
- def push_uint32(buf: Buffer, v: int) -> None:
- """
- Push a 32-bit unsigned integer.
- """
- pack_into("!L", buf._data, buf._pos, v)
- buf._pos += 4
-
===========changed ref 20===========
# module: aioquic.buffer
- def push_uint16(buf: Buffer, v: int) -> None:
- """
- Push a 16-bit unsigned integer.
- """
- pack_into("!H", buf._data, buf._pos, v)
- buf._pos += 2
-
|
aioquic.tls/push_key_share
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<0>:<add> buf.push_uint16(value[0])
<del> push_group(buf, value[0])
|
# module: aioquic.tls
def push_key_share(buf: Buffer, value: KeyShareEntry) -> None:
<0> push_group(buf, value[0])
<1> push_opaque(buf, 2, value[1])
<2>
|
===========unchanged ref 0===========
at: aioquic.tls
push_opaque(buf: Buffer, capacity: int, value: bytes) -> None
===========changed ref 0===========
# module: aioquic.tls
def push_opaque(buf: Buffer, capacity: int, value: bytes) -> None:
"""
Push an opaque value prefix by a length.
"""
with push_block(buf, capacity):
+ buf.push_bytes(value)
- push_bytes(buf, value)
===========changed ref 1===========
# module: aioquic.tls
@contextmanager
def push_extension(buf: Buffer, extension_type: int) -> Generator:
+ buf.push_uint16(extension_type)
- push_uint16(buf, extension_type)
with push_block(buf, 2):
yield
===========changed ref 2===========
# module: aioquic.tls
def pull_opaque(buf: Buffer, capacity: int) -> bytes:
"""
Pull an opaque value prefixed by a length.
"""
with pull_block(buf, capacity) as length:
+ return buf.pull_bytes(length)
- return pull_bytes(buf, length)
===========changed ref 3===========
# module: aioquic.tls
def push_list(
+ buf: Buffer, capacity: int, func: Callable[[T], None], values: Sequence[T]
- buf: Buffer, capacity: int, func: Callable[[Buffer, T], None], values: Sequence[T]
) -> None:
"""
Push a list of items.
"""
with push_block(buf, capacity):
for value in values:
+ func(value)
- func(buf, value)
===========changed ref 4===========
# module: aioquic.tls
def pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm:
+ return SignatureAlgorithm(buf.pull_uint16())
- return SignatureAlgorithm(pull_uint16(buf))
===========changed ref 5===========
# module: aioquic.tls
def pull_group(buf: Buffer) -> Group:
+ return Group(buf.pull_uint16())
- return Group(pull_uint16(buf))
===========changed ref 6===========
# module: aioquic.tls
def pull_key_exchange_mode(buf: Buffer) -> KeyExchangeMode:
+ return KeyExchangeMode(buf.pull_uint8())
- return KeyExchangeMode(pull_uint8(buf))
===========changed ref 7===========
# module: aioquic.tls
def pull_compression_method(buf: Buffer) -> CompressionMethod:
+ return CompressionMethod(buf.pull_uint8())
- return CompressionMethod(pull_uint8(buf))
===========changed ref 8===========
# module: aioquic.tls
# INTEGERS
def pull_cipher_suite(buf: Buffer) -> CipherSuite:
+ return CipherSuite(buf.pull_uint16())
- return CipherSuite(pull_uint16(buf))
===========changed ref 9===========
# module: aioquic.tls
# LISTS
+ def pull_list(buf: Buffer, capacity: int, func: Callable[[], T]) -> List[T]:
- def pull_list(buf: Buffer, capacity: int, func: Callable[[Buffer], T]) -> List[T]:
"""
Pull a list of items.
"""
items = []
with pull_block(buf, capacity) as length:
+ end = buf.tell() + length
- end = buf._pos + length
+ while buf.tell() < end:
- while buf._pos < end:
+ items.append(func())
- items.append(func(buf))
return items
===========changed ref 10===========
# module: aioquic.tls
- push_cipher_suite = push_uint16
- push_compression_method = push_uint8
- push_group = push_uint16
- push_key_exchange_mode = push_uint8
- push_signature_algorithm = push_uint16
-
===========changed ref 11===========
# module: aioquic.tls
# BLOCKS
@contextmanager
def pull_block(buf: Buffer, capacity: int) -> Generator:
length = 0
+ for b in buf.pull_bytes(capacity):
- for b in pull_bytes(buf, capacity):
length = (length << 8) | b
+ end = buf.tell() + length
- end = buf._pos + length
yield length
+ assert buf.tell() == end
- assert buf._pos == end
===========changed ref 12===========
# module: aioquic.tls
@contextmanager
def push_block(buf: Buffer, capacity: int) -> Generator:
"""
Context manager to push a variable-length block, with `capacity` bytes
to write the length.
"""
+ start = buf.tell() + capacity
+ buf.seek(start)
- buf._pos += capacity
- start = buf._pos
yield
+ end = buf.tell()
+ length = end - start
- length = buf._pos - start
while capacity:
+ buf.seek(start - capacity)
+ buf.push_uint8((length >> (8 * (capacity - 1))) & 0xFF)
- buf._data[start - capacity] = (length >> (8 * (capacity - 1))) & 0xFF
capacity -= 1
+ buf.seek(end)
===========changed ref 13===========
# 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")
-
===========changed ref 14===========
# module: aioquic.buffer
class Buffer:
+ def push_uint8(self, v: int) -> None:
+ """
+ Push an 8-bit unsigned integer.
+ """
+ self._data[self._pos] = v
+ self._pos += 1
+
===========changed ref 15===========
# module: aioquic.buffer
- def push_uint8(buf: Buffer, v: int) -> None:
- """
- Push an 8-bit unsigned integer.
- """
- buf._data[buf._pos] = v
- buf._pos += 1
-
===========changed ref 16===========
# module: aioquic.buffer
class Buffer:
+ def push_uint64(self, v: int) -> None:
+ """
+ Push a 64-bit unsigned integer.
+ """
+ pack_into("!Q", self._data, self._pos, v)
+ self._pos += 8
+
===========changed ref 17===========
# module: aioquic.buffer
class Buffer:
+ def push_uint32(self, v: int) -> None:
+ """
+ Push a 32-bit unsigned integer.
+ """
+ pack_into("!L", self._data, self._pos, v)
+ self._pos += 4
+
===========changed ref 18===========
# module: aioquic.buffer
class Buffer:
+ def push_uint16(self, v: int) -> None:
+ """
+ Push a 16-bit unsigned integer.
+ """
+ pack_into("!H", self._data, self._pos, v)
+ self._pos += 2
+
===========changed ref 19===========
# module: aioquic.buffer
- def push_uint64(buf: Buffer, v: int) -> None:
- """
- Push a 64-bit unsigned integer.
- """
- pack_into("!Q", buf._data, buf._pos, v)
- buf._pos += 8
-
===========changed ref 20===========
# module: aioquic.buffer
- def push_uint32(buf: Buffer, v: int) -> None:
- """
- Push a 32-bit unsigned integer.
- """
- pack_into("!L", buf._data, buf._pos, v)
- buf._pos += 4
-
===========changed ref 21===========
# module: aioquic.buffer
- def push_uint16(buf: Buffer, v: int) -> None:
- """
- Push a 16-bit unsigned integer.
- """
- pack_into("!H", buf._data, buf._pos, v)
- buf._pos += 2
-
|
aioquic.tls/pull_psk_identity
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<1>:<add> obfuscated_ticket_age = buf.pull_uint32()
<del> obfuscated_ticket_age = pull_uint32(buf)
|
# module: aioquic.tls
def pull_psk_identity(buf: Buffer) -> PskIdentity:
<0> identity = pull_opaque(buf, 2)
<1> obfuscated_ticket_age = pull_uint32(buf)
<2> return (identity, obfuscated_ticket_age)
<3>
|
===========unchanged ref 0===========
at: aioquic.buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic.tls
push_opaque(buf: Buffer, capacity: int, value: bytes) -> None
===========changed ref 0===========
# module: aioquic.tls
def push_opaque(buf: Buffer, capacity: int, value: bytes) -> None:
"""
Push an opaque value prefix by a length.
"""
with push_block(buf, capacity):
+ buf.push_bytes(value)
- push_bytes(buf, value)
===========changed ref 1===========
# module: aioquic.tls
def push_key_share(buf: Buffer, value: KeyShareEntry) -> None:
+ buf.push_uint16(value[0])
- push_group(buf, value[0])
push_opaque(buf, 2, value[1])
===========changed ref 2===========
# module: aioquic.tls
@contextmanager
def push_extension(buf: Buffer, extension_type: int) -> Generator:
+ buf.push_uint16(extension_type)
- push_uint16(buf, extension_type)
with push_block(buf, 2):
yield
===========changed ref 3===========
# module: aioquic.tls
def pull_opaque(buf: Buffer, capacity: int) -> bytes:
"""
Pull an opaque value prefixed by a length.
"""
with pull_block(buf, capacity) as length:
+ return buf.pull_bytes(length)
- return pull_bytes(buf, length)
===========changed ref 4===========
# module: aioquic.tls
def push_list(
+ buf: Buffer, capacity: int, func: Callable[[T], None], values: Sequence[T]
- buf: Buffer, capacity: int, func: Callable[[Buffer, T], None], values: Sequence[T]
) -> None:
"""
Push a list of items.
"""
with push_block(buf, capacity):
for value in values:
+ func(value)
- func(buf, value)
===========changed ref 5===========
# module: aioquic.tls
def pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm:
+ return SignatureAlgorithm(buf.pull_uint16())
- return SignatureAlgorithm(pull_uint16(buf))
===========changed ref 6===========
# module: aioquic.tls
def pull_group(buf: Buffer) -> Group:
+ return Group(buf.pull_uint16())
- return Group(pull_uint16(buf))
===========changed ref 7===========
# module: aioquic.tls
def pull_key_exchange_mode(buf: Buffer) -> KeyExchangeMode:
+ return KeyExchangeMode(buf.pull_uint8())
- return KeyExchangeMode(pull_uint8(buf))
===========changed ref 8===========
# module: aioquic.tls
def pull_compression_method(buf: Buffer) -> CompressionMethod:
+ return CompressionMethod(buf.pull_uint8())
- return CompressionMethod(pull_uint8(buf))
===========changed ref 9===========
# module: aioquic.tls
# INTEGERS
def pull_cipher_suite(buf: Buffer) -> CipherSuite:
+ return CipherSuite(buf.pull_uint16())
- return CipherSuite(pull_uint16(buf))
===========changed ref 10===========
# module: aioquic.tls
# LISTS
+ def pull_list(buf: Buffer, capacity: int, func: Callable[[], T]) -> List[T]:
- def pull_list(buf: Buffer, capacity: int, func: Callable[[Buffer], T]) -> List[T]:
"""
Pull a list of items.
"""
items = []
with pull_block(buf, capacity) as length:
+ end = buf.tell() + length
- end = buf._pos + length
+ while buf.tell() < end:
- while buf._pos < end:
+ items.append(func())
- items.append(func(buf))
return items
===========changed ref 11===========
# module: aioquic.tls
- push_cipher_suite = push_uint16
- push_compression_method = push_uint8
- push_group = push_uint16
- push_key_exchange_mode = push_uint8
- push_signature_algorithm = push_uint16
-
===========changed ref 12===========
# module: aioquic.tls
# BLOCKS
@contextmanager
def pull_block(buf: Buffer, capacity: int) -> Generator:
length = 0
+ for b in buf.pull_bytes(capacity):
- for b in pull_bytes(buf, capacity):
length = (length << 8) | b
+ end = buf.tell() + length
- end = buf._pos + length
yield length
+ assert buf.tell() == end
- assert buf._pos == end
===========changed ref 13===========
# module: aioquic.tls
@contextmanager
def push_block(buf: Buffer, capacity: int) -> Generator:
"""
Context manager to push a variable-length block, with `capacity` bytes
to write the length.
"""
+ start = buf.tell() + capacity
+ buf.seek(start)
- buf._pos += capacity
- start = buf._pos
yield
+ end = buf.tell()
+ length = end - start
- length = buf._pos - start
while capacity:
+ buf.seek(start - capacity)
+ buf.push_uint8((length >> (8 * (capacity - 1))) & 0xFF)
- buf._data[start - capacity] = (length >> (8 * (capacity - 1))) & 0xFF
capacity -= 1
+ buf.seek(end)
===========changed ref 14===========
# 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")
-
===========changed ref 15===========
# module: aioquic.buffer
class Buffer:
+ def push_uint8(self, v: int) -> None:
+ """
+ Push an 8-bit unsigned integer.
+ """
+ self._data[self._pos] = v
+ self._pos += 1
+
===========changed ref 16===========
# module: aioquic.buffer
- def push_uint8(buf: Buffer, v: int) -> None:
- """
- Push an 8-bit unsigned integer.
- """
- buf._data[buf._pos] = v
- buf._pos += 1
-
===========changed ref 17===========
# module: aioquic.buffer
class Buffer:
+ def push_uint64(self, v: int) -> None:
+ """
+ Push a 64-bit unsigned integer.
+ """
+ pack_into("!Q", self._data, self._pos, v)
+ self._pos += 8
+
===========changed ref 18===========
# module: aioquic.buffer
class Buffer:
+ def push_uint32(self, v: int) -> None:
+ """
+ Push a 32-bit unsigned integer.
+ """
+ pack_into("!L", self._data, self._pos, v)
+ self._pos += 4
+
===========changed ref 19===========
# module: aioquic.buffer
class Buffer:
+ def push_uint16(self, v: int) -> None:
+ """
+ Push a 16-bit unsigned integer.
+ """
+ pack_into("!H", self._data, self._pos, v)
+ self._pos += 2
+
===========changed ref 20===========
# module: aioquic.buffer
- def push_uint64(buf: Buffer, v: int) -> None:
- """
- Push a 64-bit unsigned integer.
- """
- pack_into("!Q", buf._data, buf._pos, v)
- buf._pos += 8
-
===========changed ref 21===========
# module: aioquic.buffer
- def push_uint32(buf: Buffer, v: int) -> None:
- """
- Push a 32-bit unsigned integer.
- """
- pack_into("!L", buf._data, buf._pos, v)
- buf._pos += 4
-
|
aioquic.tls/push_psk_identity
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<1>:<add> buf.push_uint32(entry[1])
<del> push_uint32(buf, entry[1])
|
# module: aioquic.tls
def push_psk_identity(buf: Buffer, entry: PskIdentity) -> None:
<0> push_opaque(buf, 2, entry[0])
<1> push_uint32(buf, entry[1])
<2>
|
===========unchanged ref 0===========
at: typing
Tuple = _TupleType(tuple, -1, inst=False, name='Tuple')
===========changed ref 0===========
# module: aioquic.tls
def pull_psk_identity(buf: Buffer) -> PskIdentity:
identity = pull_opaque(buf, 2)
+ obfuscated_ticket_age = buf.pull_uint32()
- obfuscated_ticket_age = pull_uint32(buf)
return (identity, obfuscated_ticket_age)
===========changed ref 1===========
# module: aioquic.tls
def push_key_share(buf: Buffer, value: KeyShareEntry) -> None:
+ buf.push_uint16(value[0])
- push_group(buf, value[0])
push_opaque(buf, 2, value[1])
===========changed ref 2===========
# module: aioquic.tls
@contextmanager
def push_extension(buf: Buffer, extension_type: int) -> Generator:
+ buf.push_uint16(extension_type)
- push_uint16(buf, extension_type)
with push_block(buf, 2):
yield
===========changed ref 3===========
# module: aioquic.tls
def push_opaque(buf: Buffer, capacity: int, value: bytes) -> None:
"""
Push an opaque value prefix by a length.
"""
with push_block(buf, capacity):
+ buf.push_bytes(value)
- push_bytes(buf, value)
===========changed ref 4===========
# module: aioquic.tls
def pull_opaque(buf: Buffer, capacity: int) -> bytes:
"""
Pull an opaque value prefixed by a length.
"""
with pull_block(buf, capacity) as length:
+ return buf.pull_bytes(length)
- return pull_bytes(buf, length)
===========changed ref 5===========
# module: aioquic.tls
def push_list(
+ buf: Buffer, capacity: int, func: Callable[[T], None], values: Sequence[T]
- buf: Buffer, capacity: int, func: Callable[[Buffer, T], None], values: Sequence[T]
) -> None:
"""
Push a list of items.
"""
with push_block(buf, capacity):
for value in values:
+ func(value)
- func(buf, value)
===========changed ref 6===========
# module: aioquic.tls
def pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm:
+ return SignatureAlgorithm(buf.pull_uint16())
- return SignatureAlgorithm(pull_uint16(buf))
===========changed ref 7===========
# module: aioquic.tls
def pull_group(buf: Buffer) -> Group:
+ return Group(buf.pull_uint16())
- return Group(pull_uint16(buf))
===========changed ref 8===========
# module: aioquic.tls
def pull_key_exchange_mode(buf: Buffer) -> KeyExchangeMode:
+ return KeyExchangeMode(buf.pull_uint8())
- return KeyExchangeMode(pull_uint8(buf))
===========changed ref 9===========
# module: aioquic.tls
def pull_compression_method(buf: Buffer) -> CompressionMethod:
+ return CompressionMethod(buf.pull_uint8())
- return CompressionMethod(pull_uint8(buf))
===========changed ref 10===========
# module: aioquic.tls
# INTEGERS
def pull_cipher_suite(buf: Buffer) -> CipherSuite:
+ return CipherSuite(buf.pull_uint16())
- return CipherSuite(pull_uint16(buf))
===========changed ref 11===========
# module: aioquic.tls
# LISTS
+ def pull_list(buf: Buffer, capacity: int, func: Callable[[], T]) -> List[T]:
- def pull_list(buf: Buffer, capacity: int, func: Callable[[Buffer], T]) -> List[T]:
"""
Pull a list of items.
"""
items = []
with pull_block(buf, capacity) as length:
+ end = buf.tell() + length
- end = buf._pos + length
+ while buf.tell() < end:
- while buf._pos < end:
+ items.append(func())
- items.append(func(buf))
return items
===========changed ref 12===========
# module: aioquic.tls
- push_cipher_suite = push_uint16
- push_compression_method = push_uint8
- push_group = push_uint16
- push_key_exchange_mode = push_uint8
- push_signature_algorithm = push_uint16
-
===========changed ref 13===========
# module: aioquic.tls
# BLOCKS
@contextmanager
def pull_block(buf: Buffer, capacity: int) -> Generator:
length = 0
+ for b in buf.pull_bytes(capacity):
- for b in pull_bytes(buf, capacity):
length = (length << 8) | b
+ end = buf.tell() + length
- end = buf._pos + length
yield length
+ assert buf.tell() == end
- assert buf._pos == end
===========changed ref 14===========
# module: aioquic.tls
@contextmanager
def push_block(buf: Buffer, capacity: int) -> Generator:
"""
Context manager to push a variable-length block, with `capacity` bytes
to write the length.
"""
+ start = buf.tell() + capacity
+ buf.seek(start)
- buf._pos += capacity
- start = buf._pos
yield
+ end = buf.tell()
+ length = end - start
- length = buf._pos - start
while capacity:
+ buf.seek(start - capacity)
+ buf.push_uint8((length >> (8 * (capacity - 1))) & 0xFF)
- buf._data[start - capacity] = (length >> (8 * (capacity - 1))) & 0xFF
capacity -= 1
+ buf.seek(end)
===========changed ref 15===========
# 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")
-
===========changed ref 16===========
# module: aioquic.buffer
class Buffer:
+ def push_uint8(self, v: int) -> None:
+ """
+ Push an 8-bit unsigned integer.
+ """
+ self._data[self._pos] = v
+ self._pos += 1
+
===========changed ref 17===========
# module: aioquic.buffer
- def push_uint8(buf: Buffer, v: int) -> None:
- """
- Push an 8-bit unsigned integer.
- """
- buf._data[buf._pos] = v
- buf._pos += 1
-
===========changed ref 18===========
# module: aioquic.buffer
class Buffer:
+ def push_uint64(self, v: int) -> None:
+ """
+ Push a 64-bit unsigned integer.
+ """
+ pack_into("!Q", self._data, self._pos, v)
+ self._pos += 8
+
===========changed ref 19===========
# module: aioquic.buffer
class Buffer:
+ def push_uint32(self, v: int) -> None:
+ """
+ Push a 32-bit unsigned integer.
+ """
+ pack_into("!L", self._data, self._pos, v)
+ self._pos += 4
+
===========changed ref 20===========
# module: aioquic.buffer
class Buffer:
+ def push_uint16(self, v: int) -> None:
+ """
+ Push a 16-bit unsigned integer.
+ """
+ pack_into("!H", self._data, self._pos, v)
+ self._pos += 2
+
===========changed ref 21===========
# module: aioquic.buffer
- def push_uint64(buf: Buffer, v: int) -> None:
- """
- Push a 64-bit unsigned integer.
- """
- pack_into("!Q", buf._data, buf._pos, v)
- buf._pos += 8
-
|
aioquic.tls/pull_client_hello
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<0>:<add> assert buf.pull_uint8() == HandshakeType.CLIENT_HELLO
<del> assert pull_uint8(buf) == HandshakeType.CLIENT_HELLO
<2>:<add> assert buf.pull_uint16() == TLS_VERSION_1_2
<del> assert pull_uint16(buf) == TLS_VERSION_1_2
<3>:<add> client_random = buf.pull_bytes(32)
<del> client_random = pull_bytes(buf, 32)
<8>:<add> cipher_suites=pull_list(buf, 2, partial(pull_cipher_suite, buf)),
<del> cipher_suites=pull_list(buf, 2, pull_cipher_suite),
<9>:<add> compression_methods=pull_list(
<add> buf, 1, partial(pull_compression_method, buf)
<add> ),
<del> compression_methods=pull_list(buf, 1, pull_compression_method),
<15>:<add> def pull_extension() -> None:
<del> def pull_extension(buf: Buffer) -> None:
<20>:<add> extension_type = buf.pull_uint16()
<del> extension_type = pull_uint16(buf)
<21>:<add> extension_length = buf.pull_uint16()
<del> extension_length = pull_uint16(buf)
<23>:<add> hello.key_share = pull_list(buf, 2, partial(pull_key_share, buf))
<del> hello.key_share = pull_list(buf, 2, pull_key_share)
<25>:<add> hello.supported_versions = pull_list(buf, 1, buf.pull_uint16)
<del> hello.supported_versions = pull_list(buf, 1, pull_uint16)
<27>:<add> hello.signature_algorithms = pull_list(
<del> hello.signature_algorithms = pull_list(buf, 2, pull_signature_algorithm)
|
# module: aioquic.tls
def pull_client_hello(buf: Buffer) -> ClientHello:
<0> assert pull_uint8(buf) == HandshakeType.CLIENT_HELLO
<1> with pull_block(buf, 3):
<2> assert pull_uint16(buf) == TLS_VERSION_1_2
<3> client_random = pull_bytes(buf, 32)
<4>
<5> hello = ClientHello(
<6> random=client_random,
<7> session_id=pull_opaque(buf, 1),
<8> cipher_suites=pull_list(buf, 2, pull_cipher_suite),
<9> compression_methods=pull_list(buf, 1, pull_compression_method),
<10> )
<11>
<12> # extensions
<13> after_psk = False
<14>
<15> def pull_extension(buf: Buffer) -> None:
<16> # pre_shared_key MUST be last
<17> nonlocal after_psk
<18> assert not after_psk
<19>
<20> extension_type = pull_uint16(buf)
<21> extension_length = pull_uint16(buf)
<22> if extension_type == ExtensionType.KEY_SHARE:
<23> hello.key_share = pull_list(buf, 2, pull_key_share)
<24> elif extension_type == ExtensionType.SUPPORTED_VERSIONS:
<25> hello.supported_versions = pull_list(buf, 1, pull_uint16)
<26> elif extension_type == ExtensionType.SIGNATURE_ALGORITHMS:
<27> hello.signature_algorithms = pull_list(buf, 2, pull_signature_algorithm)
<28> elif extension_type == ExtensionType.SUPPORTED_GROUPS:
<29> hello.supported_groups = pull_list(buf, 2, pull_group)
<30> elif extension_type == ExtensionType.PSK_KEY_EXCHANGE_MODES:
<31> hello.key_exchange_modes = pull_list(buf, 1, pull_key_exchange_mode)
<32> elif extension_type == ExtensionType.SERVER_NAME:
<33> with pull_block(buf, 2):
<34> assert pull_uint8(buf) == 0
<35> hello</s>
|
===========below chunk 0===========
# module: aioquic.tls
def pull_client_hello(buf: Buffer) -> ClientHello:
# offset: 1
elif extension_type == ExtensionType.ALPN:
hello.alpn_protocols = pull_list(buf, 2, pull_alpn_protocol)
elif extension_type == ExtensionType.EARLY_DATA:
hello.early_data = True
elif extension_type == ExtensionType.PRE_SHARED_KEY:
hello.pre_shared_key = OfferedPsks(
identities=pull_list(buf, 2, pull_psk_identity),
binders=pull_list(buf, 2, pull_psk_binder),
)
after_psk = True
else:
hello.other_extensions.append(
(extension_type, pull_bytes(buf, extension_length))
)
pull_list(buf, 2, pull_extension)
return hello
===========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
push_uint8(v: int) -> None
at: aioquic.tls
ExtensionType(x: Union[str, bytes, bytearray], base: int)
ExtensionType(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
HandshakeType(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
HandshakeType(x: Union[str, bytes, bytearray], base: int)
pull_key_exchange_mode(buf: Buffer) -> KeyExchangeMode
pull_group(buf: Buffer) -> Group
pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm
pull_block(buf: Buffer, capacity: int) -> Generator
push_block(buf: Buffer, capacity: int) -> Generator
pull_list(buf: Buffer, capacity: int, func: Callable[[], T]) -> List[T]
pull_opaque(buf: Buffer, capacity: int) -> bytes
pull_key_share(buf: Buffer) -> KeyShareEntry
pull_alpn_protocol(buf: Buffer) -> str
pull_psk_identity(buf: Buffer) -> PskIdentity
pull_psk_binder(buf: Buffer) -> bytes
OfferedPsks(identities: List[PskIdentity], binders: List[bytes])
===========unchanged ref 1===========
ClientHello(random: bytes, session_id: bytes, cipher_suites: List[CipherSuite], compression_methods: List[CompressionMethod], alpn_protocols: Optional[List[str]]=None, early_data: bool=False, key_exchange_modes: Optional[List[KeyExchangeMode]]=None, key_share: Optional[List[KeyShareEntry]]=None, pre_shared_key: Optional[OfferedPsks]=None, server_name: Optional[str]=None, signature_algorithms: Optional[List[SignatureAlgorithm]]=None, supported_groups: Optional[List[Group]]=None, supported_versions: Optional[List[int]]=None, other_extensions: List[Extension]=field(default_factory=list))
at: aioquic.tls.ClientHello
random: bytes
session_id: bytes
cipher_suites: List[CipherSuite]
compression_methods: List[CompressionMethod]
alpn_protocols: Optional[List[str]] = None
early_data: bool = False
key_exchange_modes: Optional[List[KeyExchangeMode]] = None
key_share: Optional[List[KeyShareEntry]] = None
pre_shared_key: Optional[OfferedPsks] = None
server_name: Optional[str] = None
signature_algorithms: Optional[List[SignatureAlgorithm]] = None
supported_groups: Optional[List[Group]] = None
supported_versions: Optional[List[int]] = None
other_extensions: List[Extension] = field(default_factory=list)
at: aioquic.tls.OfferedPsks
identities: List[PskIdentity]
binders: List[bytes]
===========unchanged ref 2===========
at: aioquic.tls.pull_client_hello
hello = ClientHello(
random=client_random,
session_id=pull_opaque(buf, 1),
cipher_suites=pull_list(buf, 2, partial(pull_cipher_suite, buf)),
compression_methods=pull_list(
buf, 1, partial(pull_compression_method, buf)
),
)
at: functools
partial(func: Callable[..., _T], *args: Any, **kwargs: Any)
partial(func, *args, **keywords, /) -> function with partial application()
===========changed ref 0===========
# module: aioquic.tls
def pull_psk_identity(buf: Buffer) -> PskIdentity:
identity = pull_opaque(buf, 2)
+ obfuscated_ticket_age = buf.pull_uint32()
- obfuscated_ticket_age = pull_uint32(buf)
return (identity, obfuscated_ticket_age)
===========changed ref 1===========
# module: aioquic.tls
def pull_opaque(buf: Buffer, capacity: int) -> bytes:
"""
Pull an opaque value prefixed by a length.
"""
with pull_block(buf, capacity) as length:
+ return buf.pull_bytes(length)
- return pull_bytes(buf, length)
===========changed ref 2===========
# module: aioquic.tls
def pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm:
+ return SignatureAlgorithm(buf.pull_uint16())
- return SignatureAlgorithm(pull_uint16(buf))
===========changed ref 3===========
# module: aioquic.tls
def pull_group(buf: Buffer) -> Group:
+ return Group(buf.pull_uint16())
- return Group(pull_uint16(buf))
===========changed ref 4===========
# module: aioquic.tls
def pull_key_exchange_mode(buf: Buffer) -> KeyExchangeMode:
+ return KeyExchangeMode(buf.pull_uint8())
- return KeyExchangeMode(pull_uint8(buf))
===========changed ref 5===========
# module: aioquic.tls
# LISTS
+ def pull_list(buf: Buffer, capacity: int, func: Callable[[], T]) -> List[T]:
- def pull_list(buf: Buffer, capacity: int, func: Callable[[Buffer], T]) -> List[T]:
"""
Pull a list of items.
"""
items = []
with pull_block(buf, capacity) as length:
+ end = buf.tell() + length
- end = buf._pos + length
+ while buf.tell() < end:
- while buf._pos < end:
+ items.append(func())
- items.append(func(buf))
return items
===========changed ref 6===========
# module: aioquic.tls
# BLOCKS
@contextmanager
def pull_block(buf: Buffer, capacity: int) -> Generator:
length = 0
+ for b in buf.pull_bytes(capacity):
- for b in pull_bytes(buf, capacity):
length = (length << 8) | b
+ end = buf.tell() + length
- end = buf._pos + length
yield length
+ assert buf.tell() == end
- assert buf._pos == end
|
aioquic.tls/push_client_hello
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<0>:<add> buf.push_uint8(HandshakeType.CLIENT_HELLO)
<del> push_uint8(buf, HandshakeType.CLIENT_HELLO)
<2>:<add> buf.push_uint16(TLS_VERSION_1_2)
<del> push_uint16(buf, TLS_VERSION_1_2)
<3>:<add> buf.push_bytes(hello.random)
<del> push_bytes(buf, hello.random)
<5>:<add> push_list(buf, 2, buf.push_uint16, hello.cipher_suites)
<del> push_list(buf, 2, push_cipher_suite, hello.cipher_suites)
<6>:<add> push_list(buf, 1, buf.push_uint8, hello.compression_methods)
<del> push_list(buf, 1, push_compression_method, hello.compression_methods)
<11>:<add> push_list(buf, 2, partial(push_key_share, buf), hello.key_share)
<del> push_list(buf, 2, push_key_share, hello.key_share)
<14>:<add> push_list(buf, 1, buf.push_uint16, hello.supported_versions)
<del> push_list(buf, 1, push_uint16, hello.supported_versions)
<17>:<add> push_list(buf, 2, buf.push_uint16, hello.signature_algorithms)
<del> push_list(buf, 2, push_signature_algorithm, hello.signature_algorithms)
<20>:<add> push_list(buf, 2, buf.push_uint16, hello.supported_groups)
<del> push_list(buf, 2, push_group, hello.supported_groups)
<23>:<add> push_list(buf, 1, buf.push_uint8, hello.key_exchange_modes)
|
# module: aioquic.tls
def push_client_hello(buf: Buffer, hello: ClientHello) -> None:
<0> push_uint8(buf, HandshakeType.CLIENT_HELLO)
<1> with push_block(buf, 3):
<2> push_uint16(buf, TLS_VERSION_1_2)
<3> push_bytes(buf, hello.random)
<4> push_opaque(buf, 1, hello.session_id)
<5> push_list(buf, 2, push_cipher_suite, hello.cipher_suites)
<6> push_list(buf, 1, push_compression_method, hello.compression_methods)
<7>
<8> # extensions
<9> with push_block(buf, 2):
<10> with push_extension(buf, ExtensionType.KEY_SHARE):
<11> push_list(buf, 2, push_key_share, hello.key_share)
<12>
<13> with push_extension(buf, ExtensionType.SUPPORTED_VERSIONS):
<14> push_list(buf, 1, push_uint16, hello.supported_versions)
<15>
<16> with push_extension(buf, ExtensionType.SIGNATURE_ALGORITHMS):
<17> push_list(buf, 2, push_signature_algorithm, hello.signature_algorithms)
<18>
<19> with push_extension(buf, ExtensionType.SUPPORTED_GROUPS):
<20> push_list(buf, 2, push_group, hello.supported_groups)
<21>
<22> with push_extension(buf, ExtensionType.PSK_KEY_EXCHANGE_MODES):
<23> push_list(buf, 1, push_key_exchange_mode, hello.key_exchange_modes)
<24>
<25> if hello.server_name is not None:
<26> with push_extension(buf, ExtensionType.SERVER_NAME):
<27> with push_block(buf, 2):
<28> push_uint8(buf, 0)
<29> push_opaque(buf, 2, hello.server_name.encode("ascii"))
<30>
<31> if hello.alpn_protocols is not None:
<32> with push_extension(buf, ExtensionType.ALPN):
<33> push_list</s>
|
===========below chunk 0===========
# module: aioquic.tls
def push_client_hello(buf: Buffer, hello: ClientHello) -> None:
# offset: 1
for extension_type, extension_value in hello.other_extensions:
with push_extension(buf, extension_type):
push_bytes(buf, extension_value)
if hello.early_data:
with push_extension(buf, ExtensionType.EARLY_DATA):
pass
# pre_shared_key MUST be last
if hello.pre_shared_key is not None:
with push_extension(buf, ExtensionType.PRE_SHARED_KEY):
push_list(
buf, 2, push_psk_identity, hello.pre_shared_key.identities
)
push_list(buf, 2, push_psk_binder, hello.pre_shared_key.binders)
===========unchanged ref 0===========
at: aioquic.buffer.Buffer
push_bytes(v: bytes) -> None
push_uint8(v: int) -> None
push_uint16(v: int) -> None
at: aioquic.tls
ExtensionType(x: Union[str, bytes, bytearray], base: int)
ExtensionType(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
push_block(buf: Buffer, capacity: int) -> Generator
push_list(buf: Buffer, capacity: int, func: Callable[[T], None], values: Sequence[T]) -> None
push_opaque(buf: Buffer, capacity: int, value: bytes) -> None
push_extension(buf: Buffer, extension_type: int) -> Generator
push_key_share(buf: Buffer, value: KeyShareEntry) -> None
push_alpn_protocol(buf: Buffer, protocol: str) -> None
push_psk_identity(buf: Buffer, entry: PskIdentity) -> None
at: aioquic.tls.ClientHello
session_id: bytes
cipher_suites: List[CipherSuite]
compression_methods: List[CompressionMethod]
alpn_protocols: Optional[List[str]] = None
early_data: bool = False
key_exchange_modes: Optional[List[KeyExchangeMode]] = None
key_share: Optional[List[KeyShareEntry]] = None
pre_shared_key: Optional[OfferedPsks] = None
server_name: Optional[str] = None
signature_algorithms: Optional[List[SignatureAlgorithm]] = None
supported_groups: Optional[List[Group]] = None
supported_versions: Optional[List[int]] = None
other_extensions: List[Extension] = field(default_factory=list)
at: aioquic.tls.OfferedPsks
identities: List[PskIdentity]
===========unchanged ref 1===========
at: functools
partial(func: Callable[..., _T], *args: Any, **kwargs: Any)
partial(func, *args, **keywords, /) -> function with partial application()
===========changed ref 0===========
# module: aioquic.tls
def push_psk_identity(buf: Buffer, entry: PskIdentity) -> None:
push_opaque(buf, 2, entry[0])
+ buf.push_uint32(entry[1])
- push_uint32(buf, entry[1])
===========changed ref 1===========
# module: aioquic.tls
def push_key_share(buf: Buffer, value: KeyShareEntry) -> None:
+ buf.push_uint16(value[0])
- push_group(buf, value[0])
push_opaque(buf, 2, value[1])
===========changed ref 2===========
# module: aioquic.tls
@contextmanager
def push_extension(buf: Buffer, extension_type: int) -> Generator:
+ buf.push_uint16(extension_type)
- push_uint16(buf, extension_type)
with push_block(buf, 2):
yield
===========changed ref 3===========
# module: aioquic.tls
def push_opaque(buf: Buffer, capacity: int, value: bytes) -> None:
"""
Push an opaque value prefix by a length.
"""
with push_block(buf, capacity):
+ buf.push_bytes(value)
- push_bytes(buf, value)
===========changed ref 4===========
# module: aioquic.tls
def push_list(
+ buf: Buffer, capacity: int, func: Callable[[T], None], values: Sequence[T]
- buf: Buffer, capacity: int, func: Callable[[Buffer, T], None], values: Sequence[T]
) -> None:
"""
Push a list of items.
"""
with push_block(buf, capacity):
for value in values:
+ func(value)
- func(buf, value)
===========changed ref 5===========
# module: aioquic.tls
@contextmanager
def push_block(buf: Buffer, capacity: int) -> Generator:
"""
Context manager to push a variable-length block, with `capacity` bytes
to write the length.
"""
+ start = buf.tell() + capacity
+ buf.seek(start)
- buf._pos += capacity
- start = buf._pos
yield
+ end = buf.tell()
+ length = end - start
- length = buf._pos - start
while capacity:
+ buf.seek(start - capacity)
+ buf.push_uint8((length >> (8 * (capacity - 1))) & 0xFF)
- buf._data[start - capacity] = (length >> (8 * (capacity - 1))) & 0xFF
capacity -= 1
+ buf.seek(end)
===========changed ref 6===========
# module: aioquic.buffer
class Buffer:
+ def push_uint8(self, v: int) -> None:
+ """
+ Push an 8-bit unsigned integer.
+ """
+ self._data[self._pos] = v
+ self._pos += 1
+
===========changed ref 7===========
# module: aioquic.buffer
class Buffer:
+ def push_uint16(self, v: int) -> None:
+ """
+ Push a 16-bit unsigned integer.
+ """
+ pack_into("!H", self._data, self._pos, v)
+ self._pos += 2
+
===========changed ref 8===========
# module: aioquic.buffer
class Buffer:
+ def push_bytes(self, v: bytes) -> None:
+ """
+ Push bytes.
+ """
+ end = self._pos + len(v)
+ if end > self._length:
+ raise BufferWriteError
+ self._data[self._pos : end] = v
+ self._pos = end
+
===========changed ref 9===========
# module: aioquic.tls
def pull_psk_identity(buf: Buffer) -> PskIdentity:
identity = pull_opaque(buf, 2)
+ obfuscated_ticket_age = buf.pull_uint32()
- obfuscated_ticket_age = pull_uint32(buf)
return (identity, obfuscated_ticket_age)
===========changed ref 10===========
# module: aioquic.tls
def pull_opaque(buf: Buffer, capacity: int) -> bytes:
"""
Pull an opaque value prefixed by a length.
"""
with pull_block(buf, capacity) as length:
+ return buf.pull_bytes(length)
- return pull_bytes(buf, length)
===========changed ref 11===========
# module: aioquic.tls
def pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm:
+ return SignatureAlgorithm(buf.pull_uint16())
- return SignatureAlgorithm(pull_uint16(buf))
===========changed ref 12===========
# module: aioquic.tls
def pull_group(buf: Buffer) -> Group:
+ return Group(buf.pull_uint16())
- return Group(pull_uint16(buf))
===========changed ref 13===========
# module: aioquic.tls
def pull_key_exchange_mode(buf: Buffer) -> KeyExchangeMode:
+ return KeyExchangeMode(buf.pull_uint8())
- return KeyExchangeMode(pull_uint8(buf))
|
aioquic.tls/pull_server_hello
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<0>:<add> assert buf.pull_uint8() == HandshakeType.SERVER_HELLO
<del> assert pull_uint8(buf) == HandshakeType.SERVER_HELLO
<2>:<add> assert buf.pull_uint16() == TLS_VERSION_1_2
<del> assert pull_uint16(buf) == TLS_VERSION_1_2
<3>:<add> server_random = buf.pull_bytes(32)
<del> server_random = pull_bytes(buf, 32)
<13>:<add> def pull_extension() -> None:
<del> def pull_extension(buf: Buffer) -> None:
<14>:<add> extension_type = buf.pull_uint16()
<del> extension_type = pull_uint16(buf)
<15>:<add> extension_length = buf.pull_uint16()
<del> extension_length = pull_uint16(buf)
<17>:<add> hello.supported_version = buf.pull_uint16()
<del> hello.supported_version = pull_uint16(buf)
<21>:<add> hello.pre_shared_key = buf.pull_uint16()
<del> hello.pre_shared_key = pull_uint16(buf)
<23>:<add> buf.pull_bytes(extension_length)
<del> pull_bytes(buf, extension_length)
|
# module: aioquic.tls
def pull_server_hello(buf: Buffer) -> ServerHello:
<0> assert pull_uint8(buf) == HandshakeType.SERVER_HELLO
<1> with pull_block(buf, 3):
<2> assert pull_uint16(buf) == TLS_VERSION_1_2
<3> server_random = pull_bytes(buf, 32)
<4>
<5> hello = ServerHello(
<6> random=server_random,
<7> session_id=pull_opaque(buf, 1),
<8> cipher_suite=pull_cipher_suite(buf),
<9> compression_method=pull_compression_method(buf),
<10> )
<11>
<12> # extensions
<13> def pull_extension(buf: Buffer) -> None:
<14> extension_type = pull_uint16(buf)
<15> extension_length = pull_uint16(buf)
<16> if extension_type == ExtensionType.SUPPORTED_VERSIONS:
<17> hello.supported_version = pull_uint16(buf)
<18> elif extension_type == ExtensionType.KEY_SHARE:
<19> hello.key_share = pull_key_share(buf)
<20> elif extension_type == ExtensionType.PRE_SHARED_KEY:
<21> hello.pre_shared_key = pull_uint16(buf)
<22> else:
<23> pull_bytes(buf, extension_length)
<24>
<25> pull_list(buf, 2, pull_extension)
<26>
<27> return hello
<28>
|
===========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.tls
TLS_VERSION_1_2 = 0x0303
ExtensionType(x: Union[str, bytes, bytearray], base: int)
ExtensionType(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
HandshakeType(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
HandshakeType(x: Union[str, bytes, bytearray], base: int)
pull_cipher_suite(buf: Buffer) -> CipherSuite
pull_compression_method(buf: Buffer) -> CompressionMethod
pull_block(buf: Buffer, capacity: int) -> Generator
pull_opaque(buf: Buffer, capacity: int) -> bytes
KeyShareEntry = Tuple[Group, bytes]
pull_key_share(buf: Buffer) -> KeyShareEntry
ServerHello(random: bytes, session_id: bytes, cipher_suite: CipherSuite, compression_method: CompressionMethod, key_share: Optional[KeyShareEntry]=None, pre_shared_key: Optional[int]=None, supported_version: Optional[int]=None)
at: aioquic.tls.ServerHello
random: bytes
session_id: bytes
cipher_suite: CipherSuite
compression_method: CompressionMethod
===========changed ref 0===========
# module: aioquic.tls
def pull_opaque(buf: Buffer, capacity: int) -> bytes:
"""
Pull an opaque value prefixed by a length.
"""
with pull_block(buf, capacity) as length:
+ return buf.pull_bytes(length)
- return pull_bytes(buf, length)
===========changed ref 1===========
# module: aioquic.tls
def pull_compression_method(buf: Buffer) -> CompressionMethod:
+ return CompressionMethod(buf.pull_uint8())
- return CompressionMethod(pull_uint8(buf))
===========changed ref 2===========
# module: aioquic.tls
# INTEGERS
def pull_cipher_suite(buf: Buffer) -> CipherSuite:
+ return CipherSuite(buf.pull_uint16())
- return CipherSuite(pull_uint16(buf))
===========changed ref 3===========
# module: aioquic.tls
# BLOCKS
@contextmanager
def pull_block(buf: Buffer, capacity: int) -> Generator:
length = 0
+ for b in buf.pull_bytes(capacity):
- for b in pull_bytes(buf, capacity):
length = (length << 8) | b
+ end = buf.tell() + length
- end = buf._pos + length
yield length
+ assert buf.tell() == end
- assert buf._pos == end
===========changed ref 4===========
# module: aioquic.buffer
class Buffer:
+ def pull_uint8(self) -> int:
+ """
+ Pull an 8-bit unsigned integer.
+ """
+ try:
+ v = self._data[self._pos]
+ self._pos += 1
+ return v
+ except IndexError:
+ raise BufferReadError
+
===========changed ref 5===========
# module: aioquic.buffer
class Buffer:
+ def pull_bytes(self, length: int) -> bytes:
+ """
+ Pull bytes.
+ """
+ end = self._pos + length
+ if end > self._length:
+ raise BufferReadError
+ v = bytes(self._data[self._pos : end])
+ self._pos = end
+ return v
+
===========changed ref 6===========
# module: aioquic.buffer
class Buffer:
+ def pull_uint16(self) -> int:
+ """
+ Pull a 16-bit unsigned integer.
+ """
+ try:
+ v, = struct.unpack_from("!H", self._data, self._pos)
+ self._pos += 2
+ return v
+ except struct.error:
+ raise BufferReadError
+
===========changed ref 7===========
# module: aioquic.tls
def push_psk_identity(buf: Buffer, entry: PskIdentity) -> None:
push_opaque(buf, 2, entry[0])
+ buf.push_uint32(entry[1])
- push_uint32(buf, entry[1])
===========changed ref 8===========
# module: aioquic.tls
def pull_psk_identity(buf: Buffer) -> PskIdentity:
identity = pull_opaque(buf, 2)
+ obfuscated_ticket_age = buf.pull_uint32()
- obfuscated_ticket_age = pull_uint32(buf)
return (identity, obfuscated_ticket_age)
===========changed ref 9===========
# module: aioquic.tls
def push_key_share(buf: Buffer, value: KeyShareEntry) -> None:
+ buf.push_uint16(value[0])
- push_group(buf, value[0])
push_opaque(buf, 2, value[1])
===========changed ref 10===========
# module: aioquic.tls
@contextmanager
def push_extension(buf: Buffer, extension_type: int) -> Generator:
+ buf.push_uint16(extension_type)
- push_uint16(buf, extension_type)
with push_block(buf, 2):
yield
===========changed ref 11===========
# module: aioquic.tls
def push_opaque(buf: Buffer, capacity: int, value: bytes) -> None:
"""
Push an opaque value prefix by a length.
"""
with push_block(buf, capacity):
+ buf.push_bytes(value)
- push_bytes(buf, value)
===========changed ref 12===========
# module: aioquic.tls
def push_list(
+ buf: Buffer, capacity: int, func: Callable[[T], None], values: Sequence[T]
- buf: Buffer, capacity: int, func: Callable[[Buffer, T], None], values: Sequence[T]
) -> None:
"""
Push a list of items.
"""
with push_block(buf, capacity):
for value in values:
+ func(value)
- func(buf, value)
===========changed ref 13===========
# module: aioquic.tls
def pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm:
+ return SignatureAlgorithm(buf.pull_uint16())
- return SignatureAlgorithm(pull_uint16(buf))
===========changed ref 14===========
# module: aioquic.tls
def pull_group(buf: Buffer) -> Group:
+ return Group(buf.pull_uint16())
- return Group(pull_uint16(buf))
===========changed ref 15===========
# module: aioquic.tls
def pull_key_exchange_mode(buf: Buffer) -> KeyExchangeMode:
+ return KeyExchangeMode(buf.pull_uint8())
- return KeyExchangeMode(pull_uint8(buf))
===========changed ref 16===========
# module: aioquic.tls
# LISTS
+ def pull_list(buf: Buffer, capacity: int, func: Callable[[], T]) -> List[T]:
- def pull_list(buf: Buffer, capacity: int, func: Callable[[Buffer], T]) -> List[T]:
"""
Pull a list of items.
"""
items = []
with pull_block(buf, capacity) as length:
+ end = buf.tell() + length
- end = buf._pos + length
+ while buf.tell() < end:
- while buf._pos < end:
+ items.append(func())
- items.append(func(buf))
return items
===========changed ref 17===========
# module: aioquic.tls
- push_cipher_suite = push_uint16
- push_compression_method = push_uint8
- push_group = push_uint16
- push_key_exchange_mode = push_uint8
- push_signature_algorithm = push_uint16
-
|
aioquic.tls/push_server_hello
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<0>:<add> buf.push_uint8(HandshakeType.SERVER_HELLO)
<del> push_uint8(buf, HandshakeType.SERVER_HELLO)
<2>:<add> buf.push_uint16(TLS_VERSION_1_2)
<del> push_uint16(buf, TLS_VERSION_1_2)
<3>:<add> buf.push_bytes(hello.random)
<del> push_bytes(buf, hello.random)
<6>:<add> buf.push_uint16(hello.cipher_suite)
<del> push_cipher_suite(buf, hello.cipher_suite)
<7>:<add> buf.push_uint8(hello.compression_method)
<del> push_compression_method(buf, hello.compression_method)
<13>:<add> buf.push_uint16(hello.supported_version)
<del> push_uint16(buf, hello.supported_version)
<21>:<add> buf.push_uint16(hello.pre_shared_key)
<del> push_uint16(buf, hello.pre_shared_key)
|
# module: aioquic.tls
def push_server_hello(buf: Buffer, hello: ServerHello) -> None:
<0> push_uint8(buf, HandshakeType.SERVER_HELLO)
<1> with push_block(buf, 3):
<2> push_uint16(buf, TLS_VERSION_1_2)
<3> push_bytes(buf, hello.random)
<4>
<5> push_opaque(buf, 1, hello.session_id)
<6> push_cipher_suite(buf, hello.cipher_suite)
<7> push_compression_method(buf, hello.compression_method)
<8>
<9> # extensions
<10> with push_block(buf, 2):
<11> if hello.supported_version is not None:
<12> with push_extension(buf, ExtensionType.SUPPORTED_VERSIONS):
<13> push_uint16(buf, hello.supported_version)
<14>
<15> if hello.key_share is not None:
<16> with push_extension(buf, ExtensionType.KEY_SHARE):
<17> push_key_share(buf, hello.key_share)
<18>
<19> if hello.pre_shared_key is not None:
<20> with push_extension(buf, ExtensionType.PRE_SHARED_KEY):
<21> push_uint16(buf, hello.pre_shared_key)
<22>
|
===========unchanged ref 0===========
at: aioquic.buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic.buffer.Buffer
push_bytes(v: bytes) -> None
push_uint8(v: int) -> None
push_uint16(v: int) -> None
at: aioquic.tls
TLS_VERSION_1_2 = 0x0303
ExtensionType(x: Union[str, bytes, bytearray], base: int)
ExtensionType(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
HandshakeType(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
HandshakeType(x: Union[str, bytes, bytearray], base: int)
push_block(buf: Buffer, capacity: int) -> Generator
pull_list(buf: Buffer, capacity: int, func: Callable[[], T]) -> List[T]
push_opaque(buf: Buffer, capacity: int, value: bytes) -> None
push_extension(buf: Buffer, extension_type: int) -> Generator
ServerHello(random: bytes, session_id: bytes, cipher_suite: CipherSuite, compression_method: CompressionMethod, key_share: Optional[KeyShareEntry]=None, pre_shared_key: Optional[int]=None, supported_version: Optional[int]=None)
at: aioquic.tls.ServerHello
random: bytes
session_id: bytes
cipher_suite: CipherSuite
compression_method: CompressionMethod
key_share: Optional[KeyShareEntry] = None
supported_version: Optional[int] = None
at: aioquic.tls.pull_server_hello
hello = ServerHello(
random=server_random,
session_id=pull_opaque(buf, 1),
cipher_suite=pull_cipher_suite(buf),
compression_method=pull_compression_method(buf),
)
pull_extension() -> None
===========changed ref 0===========
# module: aioquic.tls
@contextmanager
def push_extension(buf: Buffer, extension_type: int) -> Generator:
+ buf.push_uint16(extension_type)
- push_uint16(buf, extension_type)
with push_block(buf, 2):
yield
===========changed ref 1===========
# module: aioquic.tls
def push_opaque(buf: Buffer, capacity: int, value: bytes) -> None:
"""
Push an opaque value prefix by a length.
"""
with push_block(buf, capacity):
+ buf.push_bytes(value)
- push_bytes(buf, value)
===========changed ref 2===========
# module: aioquic.tls
# LISTS
+ def pull_list(buf: Buffer, capacity: int, func: Callable[[], T]) -> List[T]:
- def pull_list(buf: Buffer, capacity: int, func: Callable[[Buffer], T]) -> List[T]:
"""
Pull a list of items.
"""
items = []
with pull_block(buf, capacity) as length:
+ end = buf.tell() + length
- end = buf._pos + length
+ while buf.tell() < end:
- while buf._pos < end:
+ items.append(func())
- items.append(func(buf))
return items
===========changed ref 3===========
# module: aioquic.tls
@contextmanager
def push_block(buf: Buffer, capacity: int) -> Generator:
"""
Context manager to push a variable-length block, with `capacity` bytes
to write the length.
"""
+ start = buf.tell() + capacity
+ buf.seek(start)
- buf._pos += capacity
- start = buf._pos
yield
+ end = buf.tell()
+ length = end - start
- length = buf._pos - start
while capacity:
+ buf.seek(start - capacity)
+ buf.push_uint8((length >> (8 * (capacity - 1))) & 0xFF)
- buf._data[start - capacity] = (length >> (8 * (capacity - 1))) & 0xFF
capacity -= 1
+ buf.seek(end)
===========changed ref 4===========
# module: aioquic.buffer
class Buffer:
+ def push_uint8(self, v: int) -> None:
+ """
+ Push an 8-bit unsigned integer.
+ """
+ self._data[self._pos] = v
+ self._pos += 1
+
===========changed ref 5===========
# module: aioquic.buffer
class Buffer:
+ def push_uint16(self, v: int) -> None:
+ """
+ Push a 16-bit unsigned integer.
+ """
+ pack_into("!H", self._data, self._pos, v)
+ self._pos += 2
+
===========changed ref 6===========
# module: aioquic.buffer
class Buffer:
+ def push_bytes(self, v: bytes) -> None:
+ """
+ Push bytes.
+ """
+ end = self._pos + len(v)
+ if end > self._length:
+ raise BufferWriteError
+ self._data[self._pos : end] = v
+ self._pos = end
+
===========changed ref 7===========
# module: aioquic.tls
def push_psk_identity(buf: Buffer, entry: PskIdentity) -> None:
push_opaque(buf, 2, entry[0])
+ buf.push_uint32(entry[1])
- push_uint32(buf, entry[1])
===========changed ref 8===========
# module: aioquic.tls
def pull_psk_identity(buf: Buffer) -> PskIdentity:
identity = pull_opaque(buf, 2)
+ obfuscated_ticket_age = buf.pull_uint32()
- obfuscated_ticket_age = pull_uint32(buf)
return (identity, obfuscated_ticket_age)
===========changed ref 9===========
# module: aioquic.tls
def push_key_share(buf: Buffer, value: KeyShareEntry) -> None:
+ buf.push_uint16(value[0])
- push_group(buf, value[0])
push_opaque(buf, 2, value[1])
===========changed ref 10===========
# module: aioquic.tls
def pull_opaque(buf: Buffer, capacity: int) -> bytes:
"""
Pull an opaque value prefixed by a length.
"""
with pull_block(buf, capacity) as length:
+ return buf.pull_bytes(length)
- return pull_bytes(buf, length)
===========changed ref 11===========
# module: aioquic.tls
def push_list(
+ buf: Buffer, capacity: int, func: Callable[[T], None], values: Sequence[T]
- buf: Buffer, capacity: int, func: Callable[[Buffer, T], None], values: Sequence[T]
) -> None:
"""
Push a list of items.
"""
with push_block(buf, capacity):
for value in values:
+ func(value)
- func(buf, value)
===========changed ref 12===========
# module: aioquic.tls
def pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm:
+ return SignatureAlgorithm(buf.pull_uint16())
- return SignatureAlgorithm(pull_uint16(buf))
===========changed ref 13===========
# module: aioquic.tls
def pull_group(buf: Buffer) -> Group:
+ return Group(buf.pull_uint16())
- return Group(pull_uint16(buf))
===========changed ref 14===========
# module: aioquic.tls
def pull_key_exchange_mode(buf: Buffer) -> KeyExchangeMode:
+ return KeyExchangeMode(buf.pull_uint8())
- return KeyExchangeMode(pull_uint8(buf))
===========changed ref 15===========
# module: aioquic.tls
def pull_compression_method(buf: Buffer) -> CompressionMethod:
+ return CompressionMethod(buf.pull_uint8())
- return CompressionMethod(pull_uint8(buf))
===========changed ref 16===========
# module: aioquic.tls
# INTEGERS
def pull_cipher_suite(buf: Buffer) -> CipherSuite:
+ return CipherSuite(buf.pull_uint16())
- return CipherSuite(pull_uint16(buf))
|
aioquic.tls/pull_new_session_ticket
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<2>:<add> assert buf.pull_uint8() == HandshakeType.NEW_SESSION_TICKET
<del> assert pull_uint8(buf) == HandshakeType.NEW_SESSION_TICKET
<4>:<add> new_session_ticket.ticket_lifetime = buf.pull_uint32()
<del> new_session_ticket.ticket_lifetime = pull_uint32(buf)
<5>:<add> new_session_ticket.ticket_age_add = buf.pull_uint32()
<del> new_session_ticket.ticket_age_add = pull_uint32(buf)
<9>:<add> def pull_extension() -> None:
<del> def pull_extension(buf: Buffer) -> None:
<10>:<add> extension_type = buf.pull_uint16()
<del> extension_type = pull_uint16(buf)
<11>:<add> extension_length = buf.pull_uint16()
<del> extension_length = pull_uint16(buf)
<13>:<add> new_session_ticket.max_early_data_size = buf.pull_uint32()
<del> new_session_ticket.max_early_data_size = pull_uint32(buf)
<15>:<add> buf.pull_bytes(extension_length)
<del> pull_bytes(buf, extension_length)
|
# module: aioquic.tls
def pull_new_session_ticket(buf: Buffer) -> NewSessionTicket:
<0> new_session_ticket = NewSessionTicket()
<1>
<2> assert pull_uint8(buf) == HandshakeType.NEW_SESSION_TICKET
<3> with pull_block(buf, 3):
<4> new_session_ticket.ticket_lifetime = pull_uint32(buf)
<5> new_session_ticket.ticket_age_add = pull_uint32(buf)
<6> new_session_ticket.ticket_nonce = pull_opaque(buf, 1)
<7> new_session_ticket.ticket = pull_opaque(buf, 2)
<8>
<9> def pull_extension(buf: Buffer) -> None:
<10> extension_type = pull_uint16(buf)
<11> extension_length = pull_uint16(buf)
<12> if extension_type == ExtensionType.EARLY_DATA:
<13> new_session_ticket.max_early_data_size = pull_uint32(buf)
<14> else:
<15> pull_bytes(buf, extension_length)
<16>
<17> pull_list(buf, 2, pull_extension)
<18>
<19> return new_session_ticket
<20>
|
===========unchanged ref 0===========
at: aioquic.buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic.buffer.Buffer
pull_uint8() -> int
pull_uint16() -> int
pull_uint32() -> int
at: aioquic.tls
ExtensionType(x: Union[str, bytes, bytearray], base: int)
ExtensionType(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
HandshakeType(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
HandshakeType(x: Union[str, bytes, bytearray], base: int)
pull_block(buf: Buffer, capacity: int) -> Generator
pull_opaque(buf: Buffer, capacity: int) -> bytes
NewSessionTicket(ticket_lifetime: int=0, ticket_age_add: int=0, ticket_nonce: bytes=b"", ticket: bytes=b"", max_early_data_size: Optional[int]=None)
at: aioquic.tls.NewSessionTicket
ticket_lifetime: int = 0
ticket_age_add: int = 0
ticket_nonce: bytes = b""
ticket: bytes = b""
===========changed ref 0===========
# module: aioquic.tls
def pull_opaque(buf: Buffer, capacity: int) -> bytes:
"""
Pull an opaque value prefixed by a length.
"""
with pull_block(buf, capacity) as length:
+ return buf.pull_bytes(length)
- return pull_bytes(buf, length)
===========changed ref 1===========
# module: aioquic.tls
# BLOCKS
@contextmanager
def pull_block(buf: Buffer, capacity: int) -> Generator:
length = 0
+ for b in buf.pull_bytes(capacity):
- for b in pull_bytes(buf, capacity):
length = (length << 8) | b
+ end = buf.tell() + length
- end = buf._pos + length
yield length
+ assert buf.tell() == end
- assert buf._pos == end
===========changed ref 2===========
# module: aioquic.buffer
class Buffer:
+ def pull_uint8(self) -> int:
+ """
+ Pull an 8-bit unsigned integer.
+ """
+ try:
+ v = self._data[self._pos]
+ self._pos += 1
+ return v
+ except IndexError:
+ raise BufferReadError
+
===========changed ref 3===========
# module: aioquic.buffer
class Buffer:
+ def pull_uint32(self) -> int:
+ """
+ Pull a 32-bit unsigned integer.
+ """
+ try:
+ v, = struct.unpack_from("!L", self._data, self._pos)
+ self._pos += 4
+ return v
+ except struct.error:
+ raise BufferReadError
+
===========changed ref 4===========
# module: aioquic.buffer
class Buffer:
+ def pull_uint16(self) -> int:
+ """
+ Pull a 16-bit unsigned integer.
+ """
+ try:
+ v, = struct.unpack_from("!H", self._data, self._pos)
+ self._pos += 2
+ return v
+ except struct.error:
+ raise BufferReadError
+
===========changed ref 5===========
# module: aioquic.tls
def push_psk_identity(buf: Buffer, entry: PskIdentity) -> None:
push_opaque(buf, 2, entry[0])
+ buf.push_uint32(entry[1])
- push_uint32(buf, entry[1])
===========changed ref 6===========
# module: aioquic.tls
def pull_psk_identity(buf: Buffer) -> PskIdentity:
identity = pull_opaque(buf, 2)
+ obfuscated_ticket_age = buf.pull_uint32()
- obfuscated_ticket_age = pull_uint32(buf)
return (identity, obfuscated_ticket_age)
===========changed ref 7===========
# module: aioquic.tls
def push_key_share(buf: Buffer, value: KeyShareEntry) -> None:
+ buf.push_uint16(value[0])
- push_group(buf, value[0])
push_opaque(buf, 2, value[1])
===========changed ref 8===========
# module: aioquic.tls
@contextmanager
def push_extension(buf: Buffer, extension_type: int) -> Generator:
+ buf.push_uint16(extension_type)
- push_uint16(buf, extension_type)
with push_block(buf, 2):
yield
===========changed ref 9===========
# module: aioquic.tls
def push_opaque(buf: Buffer, capacity: int, value: bytes) -> None:
"""
Push an opaque value prefix by a length.
"""
with push_block(buf, capacity):
+ buf.push_bytes(value)
- push_bytes(buf, value)
===========changed ref 10===========
# module: aioquic.tls
def push_list(
+ buf: Buffer, capacity: int, func: Callable[[T], None], values: Sequence[T]
- buf: Buffer, capacity: int, func: Callable[[Buffer, T], None], values: Sequence[T]
) -> None:
"""
Push a list of items.
"""
with push_block(buf, capacity):
for value in values:
+ func(value)
- func(buf, value)
===========changed ref 11===========
# module: aioquic.tls
def pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm:
+ return SignatureAlgorithm(buf.pull_uint16())
- return SignatureAlgorithm(pull_uint16(buf))
===========changed ref 12===========
# module: aioquic.tls
def pull_group(buf: Buffer) -> Group:
+ return Group(buf.pull_uint16())
- return Group(pull_uint16(buf))
===========changed ref 13===========
# module: aioquic.tls
def push_server_hello(buf: Buffer, hello: ServerHello) -> None:
+ buf.push_uint8(HandshakeType.SERVER_HELLO)
- push_uint8(buf, HandshakeType.SERVER_HELLO)
with push_block(buf, 3):
+ buf.push_uint16(TLS_VERSION_1_2)
- push_uint16(buf, TLS_VERSION_1_2)
+ buf.push_bytes(hello.random)
- push_bytes(buf, hello.random)
push_opaque(buf, 1, hello.session_id)
+ buf.push_uint16(hello.cipher_suite)
- push_cipher_suite(buf, hello.cipher_suite)
+ buf.push_uint8(hello.compression_method)
- push_compression_method(buf, hello.compression_method)
# extensions
with push_block(buf, 2):
if hello.supported_version is not None:
with push_extension(buf, ExtensionType.SUPPORTED_VERSIONS):
+ buf.push_uint16(hello.supported_version)
- push_uint16(buf, hello.supported_version)
if hello.key_share is not None:
with push_extension(buf, ExtensionType.KEY_SHARE):
push_key_share(buf, hello.key_share)
if hello.pre_shared_key is not None:
with push_extension(buf, ExtensionType.PRE_SHARED_KEY):
+ buf.push_uint16(hello.pre_shared_key)
- push_uint16(buf, hello.pre_shared_key)
===========changed ref 14===========
# module: aioquic.tls
def pull_key_exchange_mode(buf: Buffer) -> KeyExchangeMode:
+ return KeyExchangeMode(buf.pull_uint8())
- return KeyExchangeMode(pull_uint8(buf))
===========changed ref 15===========
# module: aioquic.tls
def pull_compression_method(buf: Buffer) -> CompressionMethod:
+ return CompressionMethod(buf.pull_uint8())
- return CompressionMethod(pull_uint8(buf))
|
aioquic.tls/push_new_session_ticket
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<0>:<add> buf.push_uint8(HandshakeType.NEW_SESSION_TICKET)
<del> push_uint8(buf, HandshakeType.NEW_SESSION_TICKET)
<2>:<add> buf.push_uint32(new_session_ticket.ticket_lifetime)
<del> push_uint32(buf, new_session_ticket.ticket_lifetime)
<3>:<add> buf.push_uint32(new_session_ticket.ticket_age_add)
<del> push_uint32(buf, new_session_ticket.ticket_age_add)
<10>:<add> buf.push_uint32(new_session_ticket.max_early_data_size)
<del> push_uint32(buf, new_session_ticket.max_early_data_size)
|
# module: aioquic.tls
def push_new_session_ticket(buf: Buffer, new_session_ticket: NewSessionTicket) -> None:
<0> push_uint8(buf, HandshakeType.NEW_SESSION_TICKET)
<1> with push_block(buf, 3):
<2> push_uint32(buf, new_session_ticket.ticket_lifetime)
<3> push_uint32(buf, new_session_ticket.ticket_age_add)
<4> push_opaque(buf, 1, new_session_ticket.ticket_nonce)
<5> push_opaque(buf, 2, new_session_ticket.ticket)
<6>
<7> with push_block(buf, 2):
<8> if new_session_ticket.max_early_data_size is not None:
<9> with push_extension(buf, ExtensionType.EARLY_DATA):
<10> push_uint32(buf, new_session_ticket.max_early_data_size)
<11>
|
===========unchanged ref 0===========
at: aioquic.buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic.buffer.Buffer
push_uint8(v: int) -> None
push_uint32(v: int) -> None
at: aioquic.tls
HandshakeType(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
HandshakeType(x: Union[str, bytes, bytearray], base: int)
push_block(buf: Buffer, capacity: int) -> Generator
pull_list(buf: Buffer, capacity: int, func: Callable[[], T]) -> List[T]
push_opaque(buf: Buffer, capacity: int, value: bytes) -> None
NewSessionTicket(ticket_lifetime: int=0, ticket_age_add: int=0, ticket_nonce: bytes=b"", ticket: bytes=b"", max_early_data_size: Optional[int]=None)
at: aioquic.tls.NewSessionTicket
ticket_lifetime: int = 0
ticket_age_add: int = 0
ticket_nonce: bytes = b""
ticket: bytes = b""
at: aioquic.tls.pull_new_session_ticket
new_session_ticket = NewSessionTicket()
pull_extension() -> None
===========changed ref 0===========
# module: aioquic.tls
def push_opaque(buf: Buffer, capacity: int, value: bytes) -> None:
"""
Push an opaque value prefix by a length.
"""
with push_block(buf, capacity):
+ buf.push_bytes(value)
- push_bytes(buf, value)
===========changed ref 1===========
# module: aioquic.tls
# LISTS
+ def pull_list(buf: Buffer, capacity: int, func: Callable[[], T]) -> List[T]:
- def pull_list(buf: Buffer, capacity: int, func: Callable[[Buffer], T]) -> List[T]:
"""
Pull a list of items.
"""
items = []
with pull_block(buf, capacity) as length:
+ end = buf.tell() + length
- end = buf._pos + length
+ while buf.tell() < end:
- while buf._pos < end:
+ items.append(func())
- items.append(func(buf))
return items
===========changed ref 2===========
# module: aioquic.tls
@contextmanager
def push_block(buf: Buffer, capacity: int) -> Generator:
"""
Context manager to push a variable-length block, with `capacity` bytes
to write the length.
"""
+ start = buf.tell() + capacity
+ buf.seek(start)
- buf._pos += capacity
- start = buf._pos
yield
+ end = buf.tell()
+ length = end - start
- length = buf._pos - start
while capacity:
+ buf.seek(start - capacity)
+ buf.push_uint8((length >> (8 * (capacity - 1))) & 0xFF)
- buf._data[start - capacity] = (length >> (8 * (capacity - 1))) & 0xFF
capacity -= 1
+ buf.seek(end)
===========changed ref 3===========
# module: aioquic.buffer
class Buffer:
+ def push_uint8(self, v: int) -> None:
+ """
+ Push an 8-bit unsigned integer.
+ """
+ self._data[self._pos] = v
+ self._pos += 1
+
===========changed ref 4===========
# module: aioquic.buffer
class Buffer:
+ def push_uint32(self, v: int) -> None:
+ """
+ Push a 32-bit unsigned integer.
+ """
+ pack_into("!L", self._data, self._pos, v)
+ self._pos += 4
+
===========changed ref 5===========
# module: aioquic.tls
def push_psk_identity(buf: Buffer, entry: PskIdentity) -> None:
push_opaque(buf, 2, entry[0])
+ buf.push_uint32(entry[1])
- push_uint32(buf, entry[1])
===========changed ref 6===========
# module: aioquic.tls
def pull_psk_identity(buf: Buffer) -> PskIdentity:
identity = pull_opaque(buf, 2)
+ obfuscated_ticket_age = buf.pull_uint32()
- obfuscated_ticket_age = pull_uint32(buf)
return (identity, obfuscated_ticket_age)
===========changed ref 7===========
# module: aioquic.tls
def push_key_share(buf: Buffer, value: KeyShareEntry) -> None:
+ buf.push_uint16(value[0])
- push_group(buf, value[0])
push_opaque(buf, 2, value[1])
===========changed ref 8===========
# module: aioquic.tls
@contextmanager
def push_extension(buf: Buffer, extension_type: int) -> Generator:
+ buf.push_uint16(extension_type)
- push_uint16(buf, extension_type)
with push_block(buf, 2):
yield
===========changed ref 9===========
# module: aioquic.tls
def pull_opaque(buf: Buffer, capacity: int) -> bytes:
"""
Pull an opaque value prefixed by a length.
"""
with pull_block(buf, capacity) as length:
+ return buf.pull_bytes(length)
- return pull_bytes(buf, length)
===========changed ref 10===========
# module: aioquic.tls
def push_list(
+ buf: Buffer, capacity: int, func: Callable[[T], None], values: Sequence[T]
- buf: Buffer, capacity: int, func: Callable[[Buffer, T], None], values: Sequence[T]
) -> None:
"""
Push a list of items.
"""
with push_block(buf, capacity):
for value in values:
+ func(value)
- func(buf, value)
===========changed ref 11===========
# module: aioquic.tls
def pull_new_session_ticket(buf: Buffer) -> NewSessionTicket:
new_session_ticket = NewSessionTicket()
+ assert buf.pull_uint8() == HandshakeType.NEW_SESSION_TICKET
- assert pull_uint8(buf) == HandshakeType.NEW_SESSION_TICKET
with pull_block(buf, 3):
+ new_session_ticket.ticket_lifetime = buf.pull_uint32()
- new_session_ticket.ticket_lifetime = pull_uint32(buf)
+ new_session_ticket.ticket_age_add = buf.pull_uint32()
- new_session_ticket.ticket_age_add = pull_uint32(buf)
new_session_ticket.ticket_nonce = pull_opaque(buf, 1)
new_session_ticket.ticket = pull_opaque(buf, 2)
+ def pull_extension() -> None:
- def pull_extension(buf: Buffer) -> None:
+ extension_type = buf.pull_uint16()
- extension_type = pull_uint16(buf)
+ extension_length = buf.pull_uint16()
- extension_length = pull_uint16(buf)
if extension_type == ExtensionType.EARLY_DATA:
+ new_session_ticket.max_early_data_size = buf.pull_uint32()
- new_session_ticket.max_early_data_size = pull_uint32(buf)
else:
+ buf.pull_bytes(extension_length)
- pull_bytes(buf, extension_length)
pull_list(buf, 2, pull_extension)
return new_session_ticket
===========changed ref 12===========
# module: aioquic.tls
def pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm:
+ return SignatureAlgorithm(buf.pull_uint16())
- return SignatureAlgorithm(pull_uint16(buf))
===========changed ref 13===========
# module: aioquic.tls
def pull_group(buf: Buffer) -> Group:
+ return Group(buf.pull_uint16())
- return Group(pull_uint16(buf))
|
aioquic.tls/pull_encrypted_extensions
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<2>:<add> assert buf.pull_uint8() == HandshakeType.ENCRYPTED_EXTENSIONS
<del> assert pull_uint8(buf) == HandshakeType.ENCRYPTED_EXTENSIONS
<5>:<add> def pull_extension() -> None:
<del> def pull_extension(buf: Buffer) -> None:
<6>:<add> extension_type = buf.pull_uint16()
<del> extension_type = pull_uint16(buf)
<7>:<add> extension_length = buf.pull_uint16()
<del> extension_length = pull_uint16(buf)
<9>:<add> extensions.alpn_protocol = pull_list(
<del> extensions.alpn_protocol = pull_list(buf, 2, pull_alpn_protocol)[0]
<10>:<add> buf, 2, partial(pull_alpn_protocol, buf)
<add> )[0]
<14>:<add> (extension_type, buf.pull_bytes(extension_length))
<del> (extension_type, pull_bytes(buf, extension_length))
|
# module: aioquic.tls
def pull_encrypted_extensions(buf: Buffer) -> EncryptedExtensions:
<0> extensions = EncryptedExtensions()
<1>
<2> assert pull_uint8(buf) == HandshakeType.ENCRYPTED_EXTENSIONS
<3> with pull_block(buf, 3):
<4>
<5> def pull_extension(buf: Buffer) -> None:
<6> extension_type = pull_uint16(buf)
<7> extension_length = pull_uint16(buf)
<8> if extension_type == ExtensionType.ALPN:
<9> extensions.alpn_protocol = pull_list(buf, 2, pull_alpn_protocol)[0]
<10> elif extension_type == ExtensionType.EARLY_DATA:
<11> extensions.early_data = True
<12> else:
<13> extensions.other_extensions.append(
<14> (extension_type, pull_bytes(buf, extension_length))
<15> )
<16>
<17> pull_list(buf, 2, pull_extension)
<18>
<19> return extensions
<20>
|
===========unchanged ref 0===========
at: aioquic.buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic.buffer.Buffer
pull_uint8() -> int
pull_uint16() -> int
at: aioquic.tls
ExtensionType(x: Union[str, bytes, bytearray], base: int)
ExtensionType(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
HandshakeType(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
HandshakeType(x: Union[str, bytes, bytearray], base: int)
pull_block(buf: Buffer, capacity: int) -> Generator
pull_list(buf: Buffer, capacity: int, func: Callable[[], T]) -> List[T]
pull_alpn_protocol(buf: Buffer) -> str
EncryptedExtensions(alpn_protocol: Optional[str]=None, early_data: bool=False, other_extensions: List[Tuple[int, bytes]]=field(default_factory=list))
at: aioquic.tls.EncryptedExtensions
alpn_protocol: Optional[str] = None
at: dataclasses
field(*, default_factory: Callable[[], _T], init: bool=..., repr: bool=..., hash: Optional[bool]=..., compare: bool=..., metadata: Optional[Mapping[str, Any]]=...) -> _T
field(*, init: bool=..., repr: bool=..., hash: Optional[bool]=..., compare: bool=..., metadata: Optional[Mapping[str, Any]]=...) -> Any
field(*, default: _T, init: bool=..., repr: bool=..., hash: Optional[bool]=..., compare: bool=..., metadata: Optional[Mapping[str, Any]]=...) -> _T
at: functools
partial(func: Callable[..., _T], *args: Any, **kwargs: Any)
partial(func, *args, **keywords, /) -> function with partial application()
===========unchanged ref 1===========
at: typing
Tuple = _TupleType(tuple, -1, inst=False, name='Tuple')
List = _alias(list, 1, inst=False, name='List')
===========changed ref 0===========
# module: aioquic.tls
# LISTS
+ def pull_list(buf: Buffer, capacity: int, func: Callable[[], T]) -> List[T]:
- def pull_list(buf: Buffer, capacity: int, func: Callable[[Buffer], T]) -> List[T]:
"""
Pull a list of items.
"""
items = []
with pull_block(buf, capacity) as length:
+ end = buf.tell() + length
- end = buf._pos + length
+ while buf.tell() < end:
- while buf._pos < end:
+ items.append(func())
- items.append(func(buf))
return items
===========changed ref 1===========
# module: aioquic.tls
# BLOCKS
@contextmanager
def pull_block(buf: Buffer, capacity: int) -> Generator:
length = 0
+ for b in buf.pull_bytes(capacity):
- for b in pull_bytes(buf, capacity):
length = (length << 8) | b
+ end = buf.tell() + length
- end = buf._pos + length
yield length
+ assert buf.tell() == end
- assert buf._pos == end
===========changed ref 2===========
# module: aioquic.buffer
class Buffer:
+ def pull_uint8(self) -> int:
+ """
+ Pull an 8-bit unsigned integer.
+ """
+ try:
+ v = self._data[self._pos]
+ self._pos += 1
+ return v
+ except IndexError:
+ raise BufferReadError
+
===========changed ref 3===========
# module: aioquic.buffer
class Buffer:
+ def pull_uint16(self) -> int:
+ """
+ Pull a 16-bit unsigned integer.
+ """
+ try:
+ v, = struct.unpack_from("!H", self._data, self._pos)
+ self._pos += 2
+ return v
+ except struct.error:
+ raise BufferReadError
+
===========changed ref 4===========
# module: aioquic.tls
def push_new_session_ticket(buf: Buffer, new_session_ticket: NewSessionTicket) -> None:
+ buf.push_uint8(HandshakeType.NEW_SESSION_TICKET)
- push_uint8(buf, HandshakeType.NEW_SESSION_TICKET)
with push_block(buf, 3):
+ buf.push_uint32(new_session_ticket.ticket_lifetime)
- push_uint32(buf, new_session_ticket.ticket_lifetime)
+ buf.push_uint32(new_session_ticket.ticket_age_add)
- push_uint32(buf, new_session_ticket.ticket_age_add)
push_opaque(buf, 1, new_session_ticket.ticket_nonce)
push_opaque(buf, 2, new_session_ticket.ticket)
with push_block(buf, 2):
if new_session_ticket.max_early_data_size is not None:
with push_extension(buf, ExtensionType.EARLY_DATA):
+ buf.push_uint32(new_session_ticket.max_early_data_size)
- push_uint32(buf, new_session_ticket.max_early_data_size)
===========changed ref 5===========
# module: aioquic.tls
def push_psk_identity(buf: Buffer, entry: PskIdentity) -> None:
push_opaque(buf, 2, entry[0])
+ buf.push_uint32(entry[1])
- push_uint32(buf, entry[1])
===========changed ref 6===========
# module: aioquic.tls
def pull_psk_identity(buf: Buffer) -> PskIdentity:
identity = pull_opaque(buf, 2)
+ obfuscated_ticket_age = buf.pull_uint32()
- obfuscated_ticket_age = pull_uint32(buf)
return (identity, obfuscated_ticket_age)
===========changed ref 7===========
# module: aioquic.tls
def push_key_share(buf: Buffer, value: KeyShareEntry) -> None:
+ buf.push_uint16(value[0])
- push_group(buf, value[0])
push_opaque(buf, 2, value[1])
===========changed ref 8===========
# module: aioquic.tls
@contextmanager
def push_extension(buf: Buffer, extension_type: int) -> Generator:
+ buf.push_uint16(extension_type)
- push_uint16(buf, extension_type)
with push_block(buf, 2):
yield
===========changed ref 9===========
# module: aioquic.tls
def push_opaque(buf: Buffer, capacity: int, value: bytes) -> None:
"""
Push an opaque value prefix by a length.
"""
with push_block(buf, capacity):
+ buf.push_bytes(value)
- push_bytes(buf, value)
===========changed ref 10===========
# module: aioquic.tls
def pull_opaque(buf: Buffer, capacity: int) -> bytes:
"""
Pull an opaque value prefixed by a length.
"""
with pull_block(buf, capacity) as length:
+ return buf.pull_bytes(length)
- return pull_bytes(buf, length)
===========changed ref 11===========
# module: aioquic.tls
def push_list(
+ buf: Buffer, capacity: int, func: Callable[[T], None], values: Sequence[T]
- buf: Buffer, capacity: int, func: Callable[[Buffer, T], None], values: Sequence[T]
) -> None:
"""
Push a list of items.
"""
with push_block(buf, capacity):
for value in values:
+ func(value)
- func(buf, value)
|
aioquic.tls/push_encrypted_extensions
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<0>:<add> buf.push_uint8(HandshakeType.ENCRYPTED_EXTENSIONS)
<del> push_uint8(buf, HandshakeType.ENCRYPTED_EXTENSIONS)
<5>:<add> push_list(
<add> buf,
<add> 2,
<add> partial(push_alpn_protocol, buf),
<add> [extensions.alpn_protocol],
<add> )
<del> push_list(buf, 2, push_alpn_protocol, [extensions.alpn_protocol])
<13>:<add> buf.push_bytes(extension_value)
<del> push_bytes(buf, extension_value)
|
# module: aioquic.tls
def push_encrypted_extensions(buf: Buffer, extensions: EncryptedExtensions) -> None:
<0> push_uint8(buf, HandshakeType.ENCRYPTED_EXTENSIONS)
<1> with push_block(buf, 3):
<2> with push_block(buf, 2):
<3> if extensions.alpn_protocol is not None:
<4> with push_extension(buf, ExtensionType.ALPN):
<5> push_list(buf, 2, push_alpn_protocol, [extensions.alpn_protocol])
<6>
<7> if extensions.early_data:
<8> with push_extension(buf, ExtensionType.EARLY_DATA):
<9> pass
<10>
<11> for extension_type, extension_value in extensions.other_extensions:
<12> with push_extension(buf, extension_type):
<13> push_bytes(buf, extension_value)
<14>
|
===========unchanged ref 0===========
at: aioquic.buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic.buffer.Buffer
push_uint8(v: int) -> None
at: aioquic.tls
ExtensionType(x: Union[str, bytes, bytearray], base: int)
ExtensionType(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
HandshakeType(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
HandshakeType(x: Union[str, bytes, bytearray], base: int)
push_block(buf: Buffer, capacity: int) -> Generator
pull_list(buf: Buffer, capacity: int, func: Callable[[], T]) -> List[T]
push_list(buf: Buffer, capacity: int, func: Callable[[T], None], values: Sequence[T]) -> None
push_extension(buf: Buffer, extension_type: int) -> Generator
EncryptedExtensions(alpn_protocol: Optional[str]=None, early_data: bool=False, other_extensions: List[Tuple[int, bytes]]=field(default_factory=list))
at: aioquic.tls.EncryptedExtensions
alpn_protocol: Optional[str] = None
at: aioquic.tls.pull_encrypted_extensions
extensions = EncryptedExtensions()
pull_extension() -> None
===========changed ref 0===========
# module: aioquic.tls
@contextmanager
def push_extension(buf: Buffer, extension_type: int) -> Generator:
+ buf.push_uint16(extension_type)
- push_uint16(buf, extension_type)
with push_block(buf, 2):
yield
===========changed ref 1===========
# module: aioquic.tls
def push_list(
+ buf: Buffer, capacity: int, func: Callable[[T], None], values: Sequence[T]
- buf: Buffer, capacity: int, func: Callable[[Buffer, T], None], values: Sequence[T]
) -> None:
"""
Push a list of items.
"""
with push_block(buf, capacity):
for value in values:
+ func(value)
- func(buf, value)
===========changed ref 2===========
# module: aioquic.tls
# LISTS
+ def pull_list(buf: Buffer, capacity: int, func: Callable[[], T]) -> List[T]:
- def pull_list(buf: Buffer, capacity: int, func: Callable[[Buffer], T]) -> List[T]:
"""
Pull a list of items.
"""
items = []
with pull_block(buf, capacity) as length:
+ end = buf.tell() + length
- end = buf._pos + length
+ while buf.tell() < end:
- while buf._pos < end:
+ items.append(func())
- items.append(func(buf))
return items
===========changed ref 3===========
# module: aioquic.tls
@contextmanager
def push_block(buf: Buffer, capacity: int) -> Generator:
"""
Context manager to push a variable-length block, with `capacity` bytes
to write the length.
"""
+ start = buf.tell() + capacity
+ buf.seek(start)
- buf._pos += capacity
- start = buf._pos
yield
+ end = buf.tell()
+ length = end - start
- length = buf._pos - start
while capacity:
+ buf.seek(start - capacity)
+ buf.push_uint8((length >> (8 * (capacity - 1))) & 0xFF)
- buf._data[start - capacity] = (length >> (8 * (capacity - 1))) & 0xFF
capacity -= 1
+ buf.seek(end)
===========changed ref 4===========
# module: aioquic.buffer
class Buffer:
+ def push_uint8(self, v: int) -> None:
+ """
+ Push an 8-bit unsigned integer.
+ """
+ self._data[self._pos] = v
+ self._pos += 1
+
===========changed ref 5===========
# module: aioquic.tls
def push_new_session_ticket(buf: Buffer, new_session_ticket: NewSessionTicket) -> None:
+ buf.push_uint8(HandshakeType.NEW_SESSION_TICKET)
- push_uint8(buf, HandshakeType.NEW_SESSION_TICKET)
with push_block(buf, 3):
+ buf.push_uint32(new_session_ticket.ticket_lifetime)
- push_uint32(buf, new_session_ticket.ticket_lifetime)
+ buf.push_uint32(new_session_ticket.ticket_age_add)
- push_uint32(buf, new_session_ticket.ticket_age_add)
push_opaque(buf, 1, new_session_ticket.ticket_nonce)
push_opaque(buf, 2, new_session_ticket.ticket)
with push_block(buf, 2):
if new_session_ticket.max_early_data_size is not None:
with push_extension(buf, ExtensionType.EARLY_DATA):
+ buf.push_uint32(new_session_ticket.max_early_data_size)
- push_uint32(buf, new_session_ticket.max_early_data_size)
===========changed ref 6===========
# module: aioquic.tls
def pull_encrypted_extensions(buf: Buffer) -> EncryptedExtensions:
extensions = EncryptedExtensions()
+ assert buf.pull_uint8() == HandshakeType.ENCRYPTED_EXTENSIONS
- assert pull_uint8(buf) == HandshakeType.ENCRYPTED_EXTENSIONS
with pull_block(buf, 3):
+ def pull_extension() -> None:
- def pull_extension(buf: Buffer) -> None:
+ extension_type = buf.pull_uint16()
- extension_type = pull_uint16(buf)
+ extension_length = buf.pull_uint16()
- extension_length = pull_uint16(buf)
if extension_type == ExtensionType.ALPN:
+ extensions.alpn_protocol = pull_list(
- extensions.alpn_protocol = pull_list(buf, 2, pull_alpn_protocol)[0]
+ buf, 2, partial(pull_alpn_protocol, buf)
+ )[0]
elif extension_type == ExtensionType.EARLY_DATA:
extensions.early_data = True
else:
extensions.other_extensions.append(
+ (extension_type, buf.pull_bytes(extension_length))
- (extension_type, pull_bytes(buf, extension_length))
)
pull_list(buf, 2, pull_extension)
return extensions
===========changed ref 7===========
# module: aioquic.tls
def push_psk_identity(buf: Buffer, entry: PskIdentity) -> None:
push_opaque(buf, 2, entry[0])
+ buf.push_uint32(entry[1])
- push_uint32(buf, entry[1])
===========changed ref 8===========
# module: aioquic.tls
def pull_psk_identity(buf: Buffer) -> PskIdentity:
identity = pull_opaque(buf, 2)
+ obfuscated_ticket_age = buf.pull_uint32()
- obfuscated_ticket_age = pull_uint32(buf)
return (identity, obfuscated_ticket_age)
===========changed ref 9===========
# module: aioquic.tls
def push_key_share(buf: Buffer, value: KeyShareEntry) -> None:
+ buf.push_uint16(value[0])
- push_group(buf, value[0])
push_opaque(buf, 2, value[1])
===========changed ref 10===========
# module: aioquic.tls
def push_opaque(buf: Buffer, capacity: int, value: bytes) -> None:
"""
Push an opaque value prefix by a length.
"""
with push_block(buf, capacity):
+ buf.push_bytes(value)
- push_bytes(buf, value)
|
aioquic.tls/pull_certificate
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<2>:<add> assert buf.pull_uint8() == HandshakeType.CERTIFICATE
<del> assert pull_uint8(buf) == HandshakeType.CERTIFICATE
<11>:<add> certificate.certificates = pull_list(
<add> buf, 3, partial(pull_certificate_entry, buf)
<add> )
<del> certificate.certificates = pull_list(buf, 3, pull_certificate_entry)
|
# module: aioquic.tls
def pull_certificate(buf: Buffer) -> Certificate:
<0> certificate = Certificate()
<1>
<2> assert pull_uint8(buf) == HandshakeType.CERTIFICATE
<3> with pull_block(buf, 3):
<4> certificate.request_context = pull_opaque(buf, 1)
<5>
<6> def pull_certificate_entry(buf: Buffer) -> CertificateEntry:
<7> data = pull_opaque(buf, 3)
<8> extensions = pull_opaque(buf, 2)
<9> return (data, extensions)
<10>
<11> certificate.certificates = pull_list(buf, 3, pull_certificate_entry)
<12>
<13> return certificate
<14>
|
===========unchanged ref 0===========
at: aioquic.buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic.buffer.Buffer
push_bytes(v: bytes) -> None
at: dataclasses
field(*, default_factory: Callable[[], _T], init: bool=..., repr: bool=..., hash: Optional[bool]=..., compare: bool=..., metadata: Optional[Mapping[str, Any]]=...) -> _T
field(*, init: bool=..., repr: bool=..., hash: Optional[bool]=..., compare: bool=..., metadata: Optional[Mapping[str, Any]]=...) -> Any
field(*, default: _T, init: bool=..., repr: bool=..., hash: Optional[bool]=..., compare: bool=..., metadata: Optional[Mapping[str, Any]]=...) -> _T
dataclass(*, init: bool=..., repr: bool=..., eq: bool=..., order: bool=..., unsafe_hash: bool=..., frozen: bool=...) -> Callable[[Type[_T]], Type[_T]]
dataclass(_cls: None) -> Callable[[Type[_T]], Type[_T]]
dataclass(_cls: Type[_T]) -> Type[_T]
at: typing
Tuple = _TupleType(tuple, -1, inst=False, name='Tuple')
List = _alias(list, 1, inst=False, name='List')
===========changed ref 0===========
# module: aioquic.buffer
class Buffer:
+ def push_bytes(self, v: bytes) -> None:
+ """
+ Push bytes.
+ """
+ end = self._pos + len(v)
+ if end > self._length:
+ raise BufferWriteError
+ self._data[self._pos : end] = v
+ self._pos = end
+
===========changed ref 1===========
# module: aioquic.tls
def push_encrypted_extensions(buf: Buffer, extensions: EncryptedExtensions) -> None:
+ buf.push_uint8(HandshakeType.ENCRYPTED_EXTENSIONS)
- push_uint8(buf, HandshakeType.ENCRYPTED_EXTENSIONS)
with push_block(buf, 3):
with push_block(buf, 2):
if extensions.alpn_protocol is not None:
with push_extension(buf, ExtensionType.ALPN):
+ push_list(
+ buf,
+ 2,
+ partial(push_alpn_protocol, buf),
+ [extensions.alpn_protocol],
+ )
- push_list(buf, 2, push_alpn_protocol, [extensions.alpn_protocol])
if extensions.early_data:
with push_extension(buf, ExtensionType.EARLY_DATA):
pass
for extension_type, extension_value in extensions.other_extensions:
with push_extension(buf, extension_type):
+ buf.push_bytes(extension_value)
- push_bytes(buf, extension_value)
===========changed ref 2===========
# module: aioquic.tls
def push_new_session_ticket(buf: Buffer, new_session_ticket: NewSessionTicket) -> None:
+ buf.push_uint8(HandshakeType.NEW_SESSION_TICKET)
- push_uint8(buf, HandshakeType.NEW_SESSION_TICKET)
with push_block(buf, 3):
+ buf.push_uint32(new_session_ticket.ticket_lifetime)
- push_uint32(buf, new_session_ticket.ticket_lifetime)
+ buf.push_uint32(new_session_ticket.ticket_age_add)
- push_uint32(buf, new_session_ticket.ticket_age_add)
push_opaque(buf, 1, new_session_ticket.ticket_nonce)
push_opaque(buf, 2, new_session_ticket.ticket)
with push_block(buf, 2):
if new_session_ticket.max_early_data_size is not None:
with push_extension(buf, ExtensionType.EARLY_DATA):
+ buf.push_uint32(new_session_ticket.max_early_data_size)
- push_uint32(buf, new_session_ticket.max_early_data_size)
===========changed ref 3===========
# module: aioquic.tls
def pull_encrypted_extensions(buf: Buffer) -> EncryptedExtensions:
extensions = EncryptedExtensions()
+ assert buf.pull_uint8() == HandshakeType.ENCRYPTED_EXTENSIONS
- assert pull_uint8(buf) == HandshakeType.ENCRYPTED_EXTENSIONS
with pull_block(buf, 3):
+ def pull_extension() -> None:
- def pull_extension(buf: Buffer) -> None:
+ extension_type = buf.pull_uint16()
- extension_type = pull_uint16(buf)
+ extension_length = buf.pull_uint16()
- extension_length = pull_uint16(buf)
if extension_type == ExtensionType.ALPN:
+ extensions.alpn_protocol = pull_list(
- extensions.alpn_protocol = pull_list(buf, 2, pull_alpn_protocol)[0]
+ buf, 2, partial(pull_alpn_protocol, buf)
+ )[0]
elif extension_type == ExtensionType.EARLY_DATA:
extensions.early_data = True
else:
extensions.other_extensions.append(
+ (extension_type, buf.pull_bytes(extension_length))
- (extension_type, pull_bytes(buf, extension_length))
)
pull_list(buf, 2, pull_extension)
return extensions
===========changed ref 4===========
# module: aioquic.tls
def push_psk_identity(buf: Buffer, entry: PskIdentity) -> None:
push_opaque(buf, 2, entry[0])
+ buf.push_uint32(entry[1])
- push_uint32(buf, entry[1])
===========changed ref 5===========
# module: aioquic.tls
def pull_psk_identity(buf: Buffer) -> PskIdentity:
identity = pull_opaque(buf, 2)
+ obfuscated_ticket_age = buf.pull_uint32()
- obfuscated_ticket_age = pull_uint32(buf)
return (identity, obfuscated_ticket_age)
===========changed ref 6===========
# module: aioquic.tls
def push_key_share(buf: Buffer, value: KeyShareEntry) -> None:
+ buf.push_uint16(value[0])
- push_group(buf, value[0])
push_opaque(buf, 2, value[1])
===========changed ref 7===========
# module: aioquic.tls
@contextmanager
def push_extension(buf: Buffer, extension_type: int) -> Generator:
+ buf.push_uint16(extension_type)
- push_uint16(buf, extension_type)
with push_block(buf, 2):
yield
===========changed ref 8===========
# module: aioquic.tls
def push_opaque(buf: Buffer, capacity: int, value: bytes) -> None:
"""
Push an opaque value prefix by a length.
"""
with push_block(buf, capacity):
+ buf.push_bytes(value)
- push_bytes(buf, value)
===========changed ref 9===========
# module: aioquic.tls
def pull_opaque(buf: Buffer, capacity: int) -> bytes:
"""
Pull an opaque value prefixed by a length.
"""
with pull_block(buf, capacity) as length:
+ return buf.pull_bytes(length)
- return pull_bytes(buf, length)
===========changed ref 10===========
# module: aioquic.tls
def push_list(
+ buf: Buffer, capacity: int, func: Callable[[T], None], values: Sequence[T]
- buf: Buffer, capacity: int, func: Callable[[Buffer, T], None], values: Sequence[T]
) -> None:
"""
Push a list of items.
"""
with push_block(buf, capacity):
for value in values:
+ func(value)
- func(buf, value)
|
aioquic.tls/push_certificate
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<0>:<add> buf.push_uint8(HandshakeType.CERTIFICATE)
<del> push_uint8(buf, HandshakeType.CERTIFICATE)
<8>:<add> push_list(
<add> buf, 3, partial(push_certificate_entry, buf), certificate.certificates
<del> push_list(buf, 3, push_certificate_entry, certificate.certificates)
<9>:<add> )
|
# module: aioquic.tls
def push_certificate(buf: Buffer, certificate: Certificate) -> None:
<0> push_uint8(buf, HandshakeType.CERTIFICATE)
<1> with push_block(buf, 3):
<2> push_opaque(buf, 1, certificate.request_context)
<3>
<4> def push_certificate_entry(buf: Buffer, entry: CertificateEntry) -> None:
<5> push_opaque(buf, 3, entry[0])
<6> push_opaque(buf, 2, entry[1])
<7>
<8> push_list(buf, 3, push_certificate_entry, certificate.certificates)
<9>
|
===========unchanged ref 0===========
at: aioquic.buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic.tls
pull_list(buf: Buffer, capacity: int, func: Callable[[], T]) -> List[T]
pull_opaque(buf: Buffer, capacity: int) -> bytes
CertificateEntry = Tuple[bytes, bytes]
at: aioquic.tls.Certificate
request_context: bytes = b""
certificates: List[CertificateEntry] = field(default_factory=list)
at: aioquic.tls.pull_certificate
certificate = Certificate()
at: functools
partial(func: Callable[..., _T], *args: Any, **kwargs: Any)
partial(func, *args, **keywords, /) -> function with partial application()
===========changed ref 0===========
# module: aioquic.tls
def pull_opaque(buf: Buffer, capacity: int) -> bytes:
"""
Pull an opaque value prefixed by a length.
"""
with pull_block(buf, capacity) as length:
+ return buf.pull_bytes(length)
- return pull_bytes(buf, length)
===========changed ref 1===========
# module: aioquic.tls
# LISTS
+ def pull_list(buf: Buffer, capacity: int, func: Callable[[], T]) -> List[T]:
- def pull_list(buf: Buffer, capacity: int, func: Callable[[Buffer], T]) -> List[T]:
"""
Pull a list of items.
"""
items = []
with pull_block(buf, capacity) as length:
+ end = buf.tell() + length
- end = buf._pos + length
+ while buf.tell() < end:
- while buf._pos < end:
+ items.append(func())
- items.append(func(buf))
return items
===========changed ref 2===========
# module: aioquic.tls
def pull_certificate(buf: Buffer) -> Certificate:
certificate = Certificate()
+ assert buf.pull_uint8() == HandshakeType.CERTIFICATE
- assert pull_uint8(buf) == HandshakeType.CERTIFICATE
with pull_block(buf, 3):
certificate.request_context = pull_opaque(buf, 1)
def pull_certificate_entry(buf: Buffer) -> CertificateEntry:
data = pull_opaque(buf, 3)
extensions = pull_opaque(buf, 2)
return (data, extensions)
+ certificate.certificates = pull_list(
+ buf, 3, partial(pull_certificate_entry, buf)
+ )
- certificate.certificates = pull_list(buf, 3, pull_certificate_entry)
return certificate
===========changed ref 3===========
# module: aioquic.tls
def push_encrypted_extensions(buf: Buffer, extensions: EncryptedExtensions) -> None:
+ buf.push_uint8(HandshakeType.ENCRYPTED_EXTENSIONS)
- push_uint8(buf, HandshakeType.ENCRYPTED_EXTENSIONS)
with push_block(buf, 3):
with push_block(buf, 2):
if extensions.alpn_protocol is not None:
with push_extension(buf, ExtensionType.ALPN):
+ push_list(
+ buf,
+ 2,
+ partial(push_alpn_protocol, buf),
+ [extensions.alpn_protocol],
+ )
- push_list(buf, 2, push_alpn_protocol, [extensions.alpn_protocol])
if extensions.early_data:
with push_extension(buf, ExtensionType.EARLY_DATA):
pass
for extension_type, extension_value in extensions.other_extensions:
with push_extension(buf, extension_type):
+ buf.push_bytes(extension_value)
- push_bytes(buf, extension_value)
===========changed ref 4===========
# module: aioquic.tls
def push_new_session_ticket(buf: Buffer, new_session_ticket: NewSessionTicket) -> None:
+ buf.push_uint8(HandshakeType.NEW_SESSION_TICKET)
- push_uint8(buf, HandshakeType.NEW_SESSION_TICKET)
with push_block(buf, 3):
+ buf.push_uint32(new_session_ticket.ticket_lifetime)
- push_uint32(buf, new_session_ticket.ticket_lifetime)
+ buf.push_uint32(new_session_ticket.ticket_age_add)
- push_uint32(buf, new_session_ticket.ticket_age_add)
push_opaque(buf, 1, new_session_ticket.ticket_nonce)
push_opaque(buf, 2, new_session_ticket.ticket)
with push_block(buf, 2):
if new_session_ticket.max_early_data_size is not None:
with push_extension(buf, ExtensionType.EARLY_DATA):
+ buf.push_uint32(new_session_ticket.max_early_data_size)
- push_uint32(buf, new_session_ticket.max_early_data_size)
===========changed ref 5===========
# module: aioquic.tls
def pull_encrypted_extensions(buf: Buffer) -> EncryptedExtensions:
extensions = EncryptedExtensions()
+ assert buf.pull_uint8() == HandshakeType.ENCRYPTED_EXTENSIONS
- assert pull_uint8(buf) == HandshakeType.ENCRYPTED_EXTENSIONS
with pull_block(buf, 3):
+ def pull_extension() -> None:
- def pull_extension(buf: Buffer) -> None:
+ extension_type = buf.pull_uint16()
- extension_type = pull_uint16(buf)
+ extension_length = buf.pull_uint16()
- extension_length = pull_uint16(buf)
if extension_type == ExtensionType.ALPN:
+ extensions.alpn_protocol = pull_list(
- extensions.alpn_protocol = pull_list(buf, 2, pull_alpn_protocol)[0]
+ buf, 2, partial(pull_alpn_protocol, buf)
+ )[0]
elif extension_type == ExtensionType.EARLY_DATA:
extensions.early_data = True
else:
extensions.other_extensions.append(
+ (extension_type, buf.pull_bytes(extension_length))
- (extension_type, pull_bytes(buf, extension_length))
)
pull_list(buf, 2, pull_extension)
return extensions
===========changed ref 6===========
# module: aioquic.tls
def push_psk_identity(buf: Buffer, entry: PskIdentity) -> None:
push_opaque(buf, 2, entry[0])
+ buf.push_uint32(entry[1])
- push_uint32(buf, entry[1])
===========changed ref 7===========
# module: aioquic.tls
def pull_psk_identity(buf: Buffer) -> PskIdentity:
identity = pull_opaque(buf, 2)
+ obfuscated_ticket_age = buf.pull_uint32()
- obfuscated_ticket_age = pull_uint32(buf)
return (identity, obfuscated_ticket_age)
===========changed ref 8===========
# module: aioquic.tls
def push_key_share(buf: Buffer, value: KeyShareEntry) -> None:
+ buf.push_uint16(value[0])
- push_group(buf, value[0])
push_opaque(buf, 2, value[1])
===========changed ref 9===========
# module: aioquic.tls
@contextmanager
def push_extension(buf: Buffer, extension_type: int) -> Generator:
+ buf.push_uint16(extension_type)
- push_uint16(buf, extension_type)
with push_block(buf, 2):
yield
===========changed ref 10===========
# module: aioquic.tls
def push_opaque(buf: Buffer, capacity: int, value: bytes) -> None:
"""
Push an opaque value prefix by a length.
"""
with push_block(buf, capacity):
+ buf.push_bytes(value)
- push_bytes(buf, value)
|
aioquic.tls/pull_certificate_verify
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<0>:<add> assert buf.pull_uint8() == HandshakeType.CERTIFICATE_VERIFY
<del> assert pull_uint8(buf) == HandshakeType.CERTIFICATE_VERIFY
|
# module: aioquic.tls
def pull_certificate_verify(buf: Buffer) -> CertificateVerify:
<0> assert pull_uint8(buf) == HandshakeType.CERTIFICATE_VERIFY
<1> with pull_block(buf, 3):
<2> algorithm = pull_signature_algorithm(buf)
<3> signature = pull_opaque(buf, 2)
<4>
<5> return CertificateVerify(algorithm=algorithm, signature=signature)
<6>
|
===========unchanged ref 0===========
at: aioquic.buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic.tls
push_list(buf: Buffer, capacity: int, func: Callable[[T], None], values: Sequence[T]) -> None
push_opaque(buf: Buffer, capacity: int, value: bytes) -> None
CertificateEntry = Tuple[bytes, bytes]
at: aioquic.tls.Certificate
certificates: List[CertificateEntry] = field(default_factory=list)
at: functools
partial(func: Callable[..., _T], *args: Any, **kwargs: Any)
partial(func, *args, **keywords, /) -> function with partial application()
===========changed ref 0===========
# module: aioquic.tls
def push_opaque(buf: Buffer, capacity: int, value: bytes) -> None:
"""
Push an opaque value prefix by a length.
"""
with push_block(buf, capacity):
+ buf.push_bytes(value)
- push_bytes(buf, value)
===========changed ref 1===========
# module: aioquic.tls
def push_list(
+ buf: Buffer, capacity: int, func: Callable[[T], None], values: Sequence[T]
- buf: Buffer, capacity: int, func: Callable[[Buffer, T], None], values: Sequence[T]
) -> None:
"""
Push a list of items.
"""
with push_block(buf, capacity):
for value in values:
+ func(value)
- func(buf, value)
===========changed ref 2===========
# module: aioquic.tls
def push_certificate(buf: Buffer, certificate: Certificate) -> None:
+ buf.push_uint8(HandshakeType.CERTIFICATE)
- push_uint8(buf, HandshakeType.CERTIFICATE)
with push_block(buf, 3):
push_opaque(buf, 1, certificate.request_context)
def push_certificate_entry(buf: Buffer, entry: CertificateEntry) -> None:
push_opaque(buf, 3, entry[0])
push_opaque(buf, 2, entry[1])
+ push_list(
+ buf, 3, partial(push_certificate_entry, buf), certificate.certificates
- push_list(buf, 3, push_certificate_entry, certificate.certificates)
+ )
===========changed ref 3===========
# module: aioquic.tls
def pull_certificate(buf: Buffer) -> Certificate:
certificate = Certificate()
+ assert buf.pull_uint8() == HandshakeType.CERTIFICATE
- assert pull_uint8(buf) == HandshakeType.CERTIFICATE
with pull_block(buf, 3):
certificate.request_context = pull_opaque(buf, 1)
def pull_certificate_entry(buf: Buffer) -> CertificateEntry:
data = pull_opaque(buf, 3)
extensions = pull_opaque(buf, 2)
return (data, extensions)
+ certificate.certificates = pull_list(
+ buf, 3, partial(pull_certificate_entry, buf)
+ )
- certificate.certificates = pull_list(buf, 3, pull_certificate_entry)
return certificate
===========changed ref 4===========
# module: aioquic.tls
def push_encrypted_extensions(buf: Buffer, extensions: EncryptedExtensions) -> None:
+ buf.push_uint8(HandshakeType.ENCRYPTED_EXTENSIONS)
- push_uint8(buf, HandshakeType.ENCRYPTED_EXTENSIONS)
with push_block(buf, 3):
with push_block(buf, 2):
if extensions.alpn_protocol is not None:
with push_extension(buf, ExtensionType.ALPN):
+ push_list(
+ buf,
+ 2,
+ partial(push_alpn_protocol, buf),
+ [extensions.alpn_protocol],
+ )
- push_list(buf, 2, push_alpn_protocol, [extensions.alpn_protocol])
if extensions.early_data:
with push_extension(buf, ExtensionType.EARLY_DATA):
pass
for extension_type, extension_value in extensions.other_extensions:
with push_extension(buf, extension_type):
+ buf.push_bytes(extension_value)
- push_bytes(buf, extension_value)
===========changed ref 5===========
# module: aioquic.tls
def push_new_session_ticket(buf: Buffer, new_session_ticket: NewSessionTicket) -> None:
+ buf.push_uint8(HandshakeType.NEW_SESSION_TICKET)
- push_uint8(buf, HandshakeType.NEW_SESSION_TICKET)
with push_block(buf, 3):
+ buf.push_uint32(new_session_ticket.ticket_lifetime)
- push_uint32(buf, new_session_ticket.ticket_lifetime)
+ buf.push_uint32(new_session_ticket.ticket_age_add)
- push_uint32(buf, new_session_ticket.ticket_age_add)
push_opaque(buf, 1, new_session_ticket.ticket_nonce)
push_opaque(buf, 2, new_session_ticket.ticket)
with push_block(buf, 2):
if new_session_ticket.max_early_data_size is not None:
with push_extension(buf, ExtensionType.EARLY_DATA):
+ buf.push_uint32(new_session_ticket.max_early_data_size)
- push_uint32(buf, new_session_ticket.max_early_data_size)
===========changed ref 6===========
# module: aioquic.tls
def pull_encrypted_extensions(buf: Buffer) -> EncryptedExtensions:
extensions = EncryptedExtensions()
+ assert buf.pull_uint8() == HandshakeType.ENCRYPTED_EXTENSIONS
- assert pull_uint8(buf) == HandshakeType.ENCRYPTED_EXTENSIONS
with pull_block(buf, 3):
+ def pull_extension() -> None:
- def pull_extension(buf: Buffer) -> None:
+ extension_type = buf.pull_uint16()
- extension_type = pull_uint16(buf)
+ extension_length = buf.pull_uint16()
- extension_length = pull_uint16(buf)
if extension_type == ExtensionType.ALPN:
+ extensions.alpn_protocol = pull_list(
- extensions.alpn_protocol = pull_list(buf, 2, pull_alpn_protocol)[0]
+ buf, 2, partial(pull_alpn_protocol, buf)
+ )[0]
elif extension_type == ExtensionType.EARLY_DATA:
extensions.early_data = True
else:
extensions.other_extensions.append(
+ (extension_type, buf.pull_bytes(extension_length))
- (extension_type, pull_bytes(buf, extension_length))
)
pull_list(buf, 2, pull_extension)
return extensions
===========changed ref 7===========
# module: aioquic.tls
def push_psk_identity(buf: Buffer, entry: PskIdentity) -> None:
push_opaque(buf, 2, entry[0])
+ buf.push_uint32(entry[1])
- push_uint32(buf, entry[1])
===========changed ref 8===========
# module: aioquic.tls
def pull_psk_identity(buf: Buffer) -> PskIdentity:
identity = pull_opaque(buf, 2)
+ obfuscated_ticket_age = buf.pull_uint32()
- obfuscated_ticket_age = pull_uint32(buf)
return (identity, obfuscated_ticket_age)
===========changed ref 9===========
# module: aioquic.tls
def push_key_share(buf: Buffer, value: KeyShareEntry) -> None:
+ buf.push_uint16(value[0])
- push_group(buf, value[0])
push_opaque(buf, 2, value[1])
|
aioquic.tls/push_certificate_verify
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<0>:<add> buf.push_uint8(HandshakeType.CERTIFICATE_VERIFY)
<del> push_uint8(buf, HandshakeType.CERTIFICATE_VERIFY)
<2>:<add> buf.push_uint16(verify.algorithm)
<del> push_signature_algorithm(buf, verify.algorithm)
|
# module: aioquic.tls
def push_certificate_verify(buf: Buffer, verify: CertificateVerify) -> None:
<0> push_uint8(buf, HandshakeType.CERTIFICATE_VERIFY)
<1> with push_block(buf, 3):
<2> push_signature_algorithm(buf, verify.algorithm)
<3> push_opaque(buf, 2, verify.signature)
<4>
|
===========unchanged ref 0===========
at: aioquic.tls
SignatureAlgorithm(x: Union[str, bytes, bytearray], base: int)
SignatureAlgorithm(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
at: dataclasses
dataclass(*, init: bool=..., repr: bool=..., eq: bool=..., order: bool=..., unsafe_hash: bool=..., frozen: bool=...) -> Callable[[Type[_T]], Type[_T]]
dataclass(_cls: None) -> Callable[[Type[_T]], Type[_T]]
dataclass(_cls: Type[_T]) -> Type[_T]
===========changed ref 0===========
# module: aioquic.tls
def pull_certificate_verify(buf: Buffer) -> CertificateVerify:
+ assert buf.pull_uint8() == HandshakeType.CERTIFICATE_VERIFY
- assert pull_uint8(buf) == HandshakeType.CERTIFICATE_VERIFY
with pull_block(buf, 3):
algorithm = pull_signature_algorithm(buf)
signature = pull_opaque(buf, 2)
return CertificateVerify(algorithm=algorithm, signature=signature)
===========changed ref 1===========
# module: aioquic.tls
def push_certificate(buf: Buffer, certificate: Certificate) -> None:
+ buf.push_uint8(HandshakeType.CERTIFICATE)
- push_uint8(buf, HandshakeType.CERTIFICATE)
with push_block(buf, 3):
push_opaque(buf, 1, certificate.request_context)
def push_certificate_entry(buf: Buffer, entry: CertificateEntry) -> None:
push_opaque(buf, 3, entry[0])
push_opaque(buf, 2, entry[1])
+ push_list(
+ buf, 3, partial(push_certificate_entry, buf), certificate.certificates
- push_list(buf, 3, push_certificate_entry, certificate.certificates)
+ )
===========changed ref 2===========
# module: aioquic.tls
def pull_certificate(buf: Buffer) -> Certificate:
certificate = Certificate()
+ assert buf.pull_uint8() == HandshakeType.CERTIFICATE
- assert pull_uint8(buf) == HandshakeType.CERTIFICATE
with pull_block(buf, 3):
certificate.request_context = pull_opaque(buf, 1)
def pull_certificate_entry(buf: Buffer) -> CertificateEntry:
data = pull_opaque(buf, 3)
extensions = pull_opaque(buf, 2)
return (data, extensions)
+ certificate.certificates = pull_list(
+ buf, 3, partial(pull_certificate_entry, buf)
+ )
- certificate.certificates = pull_list(buf, 3, pull_certificate_entry)
return certificate
===========changed ref 3===========
# module: aioquic.tls
def push_encrypted_extensions(buf: Buffer, extensions: EncryptedExtensions) -> None:
+ buf.push_uint8(HandshakeType.ENCRYPTED_EXTENSIONS)
- push_uint8(buf, HandshakeType.ENCRYPTED_EXTENSIONS)
with push_block(buf, 3):
with push_block(buf, 2):
if extensions.alpn_protocol is not None:
with push_extension(buf, ExtensionType.ALPN):
+ push_list(
+ buf,
+ 2,
+ partial(push_alpn_protocol, buf),
+ [extensions.alpn_protocol],
+ )
- push_list(buf, 2, push_alpn_protocol, [extensions.alpn_protocol])
if extensions.early_data:
with push_extension(buf, ExtensionType.EARLY_DATA):
pass
for extension_type, extension_value in extensions.other_extensions:
with push_extension(buf, extension_type):
+ buf.push_bytes(extension_value)
- push_bytes(buf, extension_value)
===========changed ref 4===========
# module: aioquic.tls
def push_new_session_ticket(buf: Buffer, new_session_ticket: NewSessionTicket) -> None:
+ buf.push_uint8(HandshakeType.NEW_SESSION_TICKET)
- push_uint8(buf, HandshakeType.NEW_SESSION_TICKET)
with push_block(buf, 3):
+ buf.push_uint32(new_session_ticket.ticket_lifetime)
- push_uint32(buf, new_session_ticket.ticket_lifetime)
+ buf.push_uint32(new_session_ticket.ticket_age_add)
- push_uint32(buf, new_session_ticket.ticket_age_add)
push_opaque(buf, 1, new_session_ticket.ticket_nonce)
push_opaque(buf, 2, new_session_ticket.ticket)
with push_block(buf, 2):
if new_session_ticket.max_early_data_size is not None:
with push_extension(buf, ExtensionType.EARLY_DATA):
+ buf.push_uint32(new_session_ticket.max_early_data_size)
- push_uint32(buf, new_session_ticket.max_early_data_size)
===========changed ref 5===========
# module: aioquic.tls
def pull_encrypted_extensions(buf: Buffer) -> EncryptedExtensions:
extensions = EncryptedExtensions()
+ assert buf.pull_uint8() == HandshakeType.ENCRYPTED_EXTENSIONS
- assert pull_uint8(buf) == HandshakeType.ENCRYPTED_EXTENSIONS
with pull_block(buf, 3):
+ def pull_extension() -> None:
- def pull_extension(buf: Buffer) -> None:
+ extension_type = buf.pull_uint16()
- extension_type = pull_uint16(buf)
+ extension_length = buf.pull_uint16()
- extension_length = pull_uint16(buf)
if extension_type == ExtensionType.ALPN:
+ extensions.alpn_protocol = pull_list(
- extensions.alpn_protocol = pull_list(buf, 2, pull_alpn_protocol)[0]
+ buf, 2, partial(pull_alpn_protocol, buf)
+ )[0]
elif extension_type == ExtensionType.EARLY_DATA:
extensions.early_data = True
else:
extensions.other_extensions.append(
+ (extension_type, buf.pull_bytes(extension_length))
- (extension_type, pull_bytes(buf, extension_length))
)
pull_list(buf, 2, pull_extension)
return extensions
===========changed ref 6===========
# module: aioquic.tls
def push_psk_identity(buf: Buffer, entry: PskIdentity) -> None:
push_opaque(buf, 2, entry[0])
+ buf.push_uint32(entry[1])
- push_uint32(buf, entry[1])
===========changed ref 7===========
# module: aioquic.tls
def pull_psk_identity(buf: Buffer) -> PskIdentity:
identity = pull_opaque(buf, 2)
+ obfuscated_ticket_age = buf.pull_uint32()
- obfuscated_ticket_age = pull_uint32(buf)
return (identity, obfuscated_ticket_age)
===========changed ref 8===========
# module: aioquic.tls
def push_key_share(buf: Buffer, value: KeyShareEntry) -> None:
+ buf.push_uint16(value[0])
- push_group(buf, value[0])
push_opaque(buf, 2, value[1])
===========changed ref 9===========
# module: aioquic.tls
@contextmanager
def push_extension(buf: Buffer, extension_type: int) -> Generator:
+ buf.push_uint16(extension_type)
- push_uint16(buf, extension_type)
with push_block(buf, 2):
yield
===========changed ref 10===========
# module: aioquic.tls
def push_opaque(buf: Buffer, capacity: int, value: bytes) -> None:
"""
Push an opaque value prefix by a length.
"""
with push_block(buf, capacity):
+ buf.push_bytes(value)
- push_bytes(buf, value)
|
aioquic.tls/pull_finished
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<2>:<add> assert buf.pull_uint8() == HandshakeType.FINISHED
<del> assert pull_uint8(buf) == HandshakeType.FINISHED
|
# module: aioquic.tls
def pull_finished(buf: Buffer) -> Finished:
<0> finished = Finished()
<1>
<2> assert pull_uint8(buf) == HandshakeType.FINISHED
<3> finished.verify_data = pull_opaque(buf, 3)
<4>
<5> return finished
<6>
|
===========unchanged ref 0===========
at: aioquic.buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic.buffer.Buffer
push_uint8(v: int) -> None
at: aioquic.tls
HandshakeType(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
HandshakeType(x: Union[str, bytes, bytearray], base: int)
push_block(buf: Buffer, capacity: int) -> Generator
CertificateVerify(algorithm: SignatureAlgorithm, signature: bytes)
at: aioquic.tls.pull_certificate_verify
algorithm = pull_signature_algorithm(buf)
signature = pull_opaque(buf, 2)
===========changed ref 0===========
# module: aioquic.tls
@contextmanager
def push_block(buf: Buffer, capacity: int) -> Generator:
"""
Context manager to push a variable-length block, with `capacity` bytes
to write the length.
"""
+ start = buf.tell() + capacity
+ buf.seek(start)
- buf._pos += capacity
- start = buf._pos
yield
+ end = buf.tell()
+ length = end - start
- length = buf._pos - start
while capacity:
+ buf.seek(start - capacity)
+ buf.push_uint8((length >> (8 * (capacity - 1))) & 0xFF)
- buf._data[start - capacity] = (length >> (8 * (capacity - 1))) & 0xFF
capacity -= 1
+ buf.seek(end)
===========changed ref 1===========
# module: aioquic.buffer
class Buffer:
+ def push_uint8(self, v: int) -> None:
+ """
+ Push an 8-bit unsigned integer.
+ """
+ self._data[self._pos] = v
+ self._pos += 1
+
===========changed ref 2===========
# module: aioquic.tls
def push_certificate_verify(buf: Buffer, verify: CertificateVerify) -> None:
+ buf.push_uint8(HandshakeType.CERTIFICATE_VERIFY)
- push_uint8(buf, HandshakeType.CERTIFICATE_VERIFY)
with push_block(buf, 3):
+ buf.push_uint16(verify.algorithm)
- push_signature_algorithm(buf, verify.algorithm)
push_opaque(buf, 2, verify.signature)
===========changed ref 3===========
# module: aioquic.tls
def pull_certificate_verify(buf: Buffer) -> CertificateVerify:
+ assert buf.pull_uint8() == HandshakeType.CERTIFICATE_VERIFY
- assert pull_uint8(buf) == HandshakeType.CERTIFICATE_VERIFY
with pull_block(buf, 3):
algorithm = pull_signature_algorithm(buf)
signature = pull_opaque(buf, 2)
return CertificateVerify(algorithm=algorithm, signature=signature)
===========changed ref 4===========
# module: aioquic.tls
def push_certificate(buf: Buffer, certificate: Certificate) -> None:
+ buf.push_uint8(HandshakeType.CERTIFICATE)
- push_uint8(buf, HandshakeType.CERTIFICATE)
with push_block(buf, 3):
push_opaque(buf, 1, certificate.request_context)
def push_certificate_entry(buf: Buffer, entry: CertificateEntry) -> None:
push_opaque(buf, 3, entry[0])
push_opaque(buf, 2, entry[1])
+ push_list(
+ buf, 3, partial(push_certificate_entry, buf), certificate.certificates
- push_list(buf, 3, push_certificate_entry, certificate.certificates)
+ )
===========changed ref 5===========
# module: aioquic.tls
def pull_certificate(buf: Buffer) -> Certificate:
certificate = Certificate()
+ assert buf.pull_uint8() == HandshakeType.CERTIFICATE
- assert pull_uint8(buf) == HandshakeType.CERTIFICATE
with pull_block(buf, 3):
certificate.request_context = pull_opaque(buf, 1)
def pull_certificate_entry(buf: Buffer) -> CertificateEntry:
data = pull_opaque(buf, 3)
extensions = pull_opaque(buf, 2)
return (data, extensions)
+ certificate.certificates = pull_list(
+ buf, 3, partial(pull_certificate_entry, buf)
+ )
- certificate.certificates = pull_list(buf, 3, pull_certificate_entry)
return certificate
===========changed ref 6===========
# module: aioquic.tls
def push_encrypted_extensions(buf: Buffer, extensions: EncryptedExtensions) -> None:
+ buf.push_uint8(HandshakeType.ENCRYPTED_EXTENSIONS)
- push_uint8(buf, HandshakeType.ENCRYPTED_EXTENSIONS)
with push_block(buf, 3):
with push_block(buf, 2):
if extensions.alpn_protocol is not None:
with push_extension(buf, ExtensionType.ALPN):
+ push_list(
+ buf,
+ 2,
+ partial(push_alpn_protocol, buf),
+ [extensions.alpn_protocol],
+ )
- push_list(buf, 2, push_alpn_protocol, [extensions.alpn_protocol])
if extensions.early_data:
with push_extension(buf, ExtensionType.EARLY_DATA):
pass
for extension_type, extension_value in extensions.other_extensions:
with push_extension(buf, extension_type):
+ buf.push_bytes(extension_value)
- push_bytes(buf, extension_value)
===========changed ref 7===========
# module: aioquic.tls
def push_new_session_ticket(buf: Buffer, new_session_ticket: NewSessionTicket) -> None:
+ buf.push_uint8(HandshakeType.NEW_SESSION_TICKET)
- push_uint8(buf, HandshakeType.NEW_SESSION_TICKET)
with push_block(buf, 3):
+ buf.push_uint32(new_session_ticket.ticket_lifetime)
- push_uint32(buf, new_session_ticket.ticket_lifetime)
+ buf.push_uint32(new_session_ticket.ticket_age_add)
- push_uint32(buf, new_session_ticket.ticket_age_add)
push_opaque(buf, 1, new_session_ticket.ticket_nonce)
push_opaque(buf, 2, new_session_ticket.ticket)
with push_block(buf, 2):
if new_session_ticket.max_early_data_size is not None:
with push_extension(buf, ExtensionType.EARLY_DATA):
+ buf.push_uint32(new_session_ticket.max_early_data_size)
- push_uint32(buf, new_session_ticket.max_early_data_size)
|
aioquic.tls/push_finished
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<0>:<add> buf.push_uint8(HandshakeType.FINISHED)
<del> push_uint8(buf, HandshakeType.FINISHED)
|
# module: aioquic.tls
def push_finished(buf: Buffer, finished: Finished) -> None:
<0> push_uint8(buf, HandshakeType.FINISHED)
<1> push_opaque(buf, 3, finished.verify_data)
<2>
|
===========unchanged ref 0===========
at: dataclasses
dataclass(*, init: bool=..., repr: bool=..., eq: bool=..., order: bool=..., unsafe_hash: bool=..., frozen: bool=...) -> Callable[[Type[_T]], Type[_T]]
dataclass(_cls: None) -> Callable[[Type[_T]], Type[_T]]
dataclass(_cls: Type[_T]) -> Type[_T]
===========changed ref 0===========
# module: aioquic.tls
def pull_finished(buf: Buffer) -> Finished:
finished = Finished()
+ assert buf.pull_uint8() == HandshakeType.FINISHED
- assert pull_uint8(buf) == HandshakeType.FINISHED
finished.verify_data = pull_opaque(buf, 3)
return finished
===========changed ref 1===========
# module: aioquic.tls
def push_certificate_verify(buf: Buffer, verify: CertificateVerify) -> None:
+ buf.push_uint8(HandshakeType.CERTIFICATE_VERIFY)
- push_uint8(buf, HandshakeType.CERTIFICATE_VERIFY)
with push_block(buf, 3):
+ buf.push_uint16(verify.algorithm)
- push_signature_algorithm(buf, verify.algorithm)
push_opaque(buf, 2, verify.signature)
===========changed ref 2===========
# module: aioquic.tls
def pull_certificate_verify(buf: Buffer) -> CertificateVerify:
+ assert buf.pull_uint8() == HandshakeType.CERTIFICATE_VERIFY
- assert pull_uint8(buf) == HandshakeType.CERTIFICATE_VERIFY
with pull_block(buf, 3):
algorithm = pull_signature_algorithm(buf)
signature = pull_opaque(buf, 2)
return CertificateVerify(algorithm=algorithm, signature=signature)
===========changed ref 3===========
# module: aioquic.tls
def push_certificate(buf: Buffer, certificate: Certificate) -> None:
+ buf.push_uint8(HandshakeType.CERTIFICATE)
- push_uint8(buf, HandshakeType.CERTIFICATE)
with push_block(buf, 3):
push_opaque(buf, 1, certificate.request_context)
def push_certificate_entry(buf: Buffer, entry: CertificateEntry) -> None:
push_opaque(buf, 3, entry[0])
push_opaque(buf, 2, entry[1])
+ push_list(
+ buf, 3, partial(push_certificate_entry, buf), certificate.certificates
- push_list(buf, 3, push_certificate_entry, certificate.certificates)
+ )
===========changed ref 4===========
# module: aioquic.tls
def pull_certificate(buf: Buffer) -> Certificate:
certificate = Certificate()
+ assert buf.pull_uint8() == HandshakeType.CERTIFICATE
- assert pull_uint8(buf) == HandshakeType.CERTIFICATE
with pull_block(buf, 3):
certificate.request_context = pull_opaque(buf, 1)
def pull_certificate_entry(buf: Buffer) -> CertificateEntry:
data = pull_opaque(buf, 3)
extensions = pull_opaque(buf, 2)
return (data, extensions)
+ certificate.certificates = pull_list(
+ buf, 3, partial(pull_certificate_entry, buf)
+ )
- certificate.certificates = pull_list(buf, 3, pull_certificate_entry)
return certificate
===========changed ref 5===========
# module: aioquic.tls
def push_encrypted_extensions(buf: Buffer, extensions: EncryptedExtensions) -> None:
+ buf.push_uint8(HandshakeType.ENCRYPTED_EXTENSIONS)
- push_uint8(buf, HandshakeType.ENCRYPTED_EXTENSIONS)
with push_block(buf, 3):
with push_block(buf, 2):
if extensions.alpn_protocol is not None:
with push_extension(buf, ExtensionType.ALPN):
+ push_list(
+ buf,
+ 2,
+ partial(push_alpn_protocol, buf),
+ [extensions.alpn_protocol],
+ )
- push_list(buf, 2, push_alpn_protocol, [extensions.alpn_protocol])
if extensions.early_data:
with push_extension(buf, ExtensionType.EARLY_DATA):
pass
for extension_type, extension_value in extensions.other_extensions:
with push_extension(buf, extension_type):
+ buf.push_bytes(extension_value)
- push_bytes(buf, extension_value)
===========changed ref 6===========
# module: aioquic.tls
def push_new_session_ticket(buf: Buffer, new_session_ticket: NewSessionTicket) -> None:
+ buf.push_uint8(HandshakeType.NEW_SESSION_TICKET)
- push_uint8(buf, HandshakeType.NEW_SESSION_TICKET)
with push_block(buf, 3):
+ buf.push_uint32(new_session_ticket.ticket_lifetime)
- push_uint32(buf, new_session_ticket.ticket_lifetime)
+ buf.push_uint32(new_session_ticket.ticket_age_add)
- push_uint32(buf, new_session_ticket.ticket_age_add)
push_opaque(buf, 1, new_session_ticket.ticket_nonce)
push_opaque(buf, 2, new_session_ticket.ticket)
with push_block(buf, 2):
if new_session_ticket.max_early_data_size is not None:
with push_extension(buf, ExtensionType.EARLY_DATA):
+ buf.push_uint32(new_session_ticket.max_early_data_size)
- push_uint32(buf, new_session_ticket.max_early_data_size)
===========changed ref 7===========
# module: aioquic.tls
def pull_encrypted_extensions(buf: Buffer) -> EncryptedExtensions:
extensions = EncryptedExtensions()
+ assert buf.pull_uint8() == HandshakeType.ENCRYPTED_EXTENSIONS
- assert pull_uint8(buf) == HandshakeType.ENCRYPTED_EXTENSIONS
with pull_block(buf, 3):
+ def pull_extension() -> None:
- def pull_extension(buf: Buffer) -> None:
+ extension_type = buf.pull_uint16()
- extension_type = pull_uint16(buf)
+ extension_length = buf.pull_uint16()
- extension_length = pull_uint16(buf)
if extension_type == ExtensionType.ALPN:
+ extensions.alpn_protocol = pull_list(
- extensions.alpn_protocol = pull_list(buf, 2, pull_alpn_protocol)[0]
+ buf, 2, partial(pull_alpn_protocol, buf)
+ )[0]
elif extension_type == ExtensionType.EARLY_DATA:
extensions.early_data = True
else:
extensions.other_extensions.append(
+ (extension_type, buf.pull_bytes(extension_length))
- (extension_type, pull_bytes(buf, extension_length))
)
pull_list(buf, 2, pull_extension)
return extensions
===========changed ref 8===========
# module: aioquic.tls
def push_psk_identity(buf: Buffer, entry: PskIdentity) -> None:
push_opaque(buf, 2, entry[0])
+ buf.push_uint32(entry[1])
- push_uint32(buf, entry[1])
===========changed ref 9===========
# module: aioquic.tls
def pull_psk_identity(buf: Buffer) -> PskIdentity:
identity = pull_opaque(buf, 2)
+ obfuscated_ticket_age = buf.pull_uint32()
- obfuscated_ticket_age = pull_uint32(buf)
return (identity, obfuscated_ticket_age)
===========changed ref 10===========
# module: aioquic.tls
def push_key_share(buf: Buffer, value: KeyShareEntry) -> None:
+ buf.push_uint16(value[0])
- push_group(buf, value[0])
push_opaque(buf, 2, value[1])
|
aioquic.packet/pull_quic_header
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<0>:<add> first_byte = buf.pull_uint8()
<del> first_byte = pull_uint8(buf)
<6>:<add> version = buf.pull_uint32()
<del> version = pull_uint32(buf)
<7>:<add> cid_lengths = buf.pull_uint8()
<del> cid_lengths = pull_uint8(buf)
<10>:<add> destination_cid = buf.pull_bytes(destination_cid_length)
<del> destination_cid = pull_bytes(buf, destination_cid_length)
<13>:<add> source_cid = buf.pull_bytes(source_cid_length)
<del> source_cid = pull_bytes(buf, source_cid_length)
<25>:<add> token_length = buf.pull_uint_var()
<del> token_length = pull_uint_var(buf)
<26>:<add> token = buf.pull_bytes(token_length)
<del> token = pull_bytes(buf, token_length)
<27>:<add> rest_length = buf.pull_uint_var()
<del> rest_length = pull_uint_var(buf)
<30>:<add> original_destination_cid = buf.pull_bytes(
<del> original_destination_cid = pull_bytes(
<31>:<add> original_destination_cid_length
<del> buf, original_destination_cid_length
<33>:<add> token = buf.pull_bytes(buf.capacity - buf.tell())
<del> token = pull_bytes(buf, buf.capacity - buf.tell())
<36>:<add> rest_length = buf.pull_uint_var()
<del> rest_length = pull_uint_var(buf)
|
# module: aioquic.packet
def pull_quic_header(buf: Buffer, host_cid_length: Optional[int] = None) -> QuicHeader:
<0> first_byte = pull_uint8(buf)
<1>
<2> original_destination_cid = b""
<3> token = b""
<4> if is_long_header(first_byte):
<5> # long header packet
<6> version = pull_uint32(buf)
<7> cid_lengths = pull_uint8(buf)
<8>
<9> destination_cid_length = decode_cid_length(cid_lengths // 16)
<10> destination_cid = pull_bytes(buf, destination_cid_length)
<11>
<12> source_cid_length = decode_cid_length(cid_lengths % 16)
<13> source_cid = pull_bytes(buf, source_cid_length)
<14>
<15> if version == QuicProtocolVersion.NEGOTIATION:
<16> # version negotiation
<17> packet_type = None
<18> rest_length = buf.capacity - buf.tell()
<19> else:
<20> if not (first_byte & PACKET_FIXED_BIT):
<21> raise ValueError("Packet fixed bit is zero")
<22>
<23> packet_type = first_byte & PACKET_TYPE_MASK
<24> if packet_type == PACKET_TYPE_INITIAL:
<25> token_length = pull_uint_var(buf)
<26> token = pull_bytes(buf, token_length)
<27> rest_length = pull_uint_var(buf)
<28> elif packet_type == PACKET_TYPE_RETRY:
<29> original_destination_cid_length = decode_cid_length(first_byte & 0xF)
<30> original_destination_cid = pull_bytes(
<31> buf, original_destination_cid_length
<32> )
<33> token = pull_bytes(buf, buf.capacity - buf.tell())
<34> rest_length = 0
<35> else:
<36> rest_length = pull_uint_var(buf)
<37>
<38> return QuicHeader(
<39> is_long_header=True,
<40> version=version,
</s>
|
===========below chunk 0===========
# module: aioquic.packet
def pull_quic_header(buf: Buffer, host_cid_length: Optional[int] = None) -> QuicHeader:
# offset: 1
destination_cid=destination_cid,
source_cid=source_cid,
original_destination_cid=original_destination_cid,
token=token,
rest_length=rest_length,
)
else:
# short header packet
if not (first_byte & PACKET_FIXED_BIT):
raise ValueError("Packet fixed bit is zero")
packet_type = first_byte & PACKET_TYPE_MASK
destination_cid = pull_bytes(buf, host_cid_length)
return QuicHeader(
is_long_header=False,
version=None,
packet_type=packet_type,
destination_cid=destination_cid,
source_cid=b"",
token=b"",
rest_length=buf.capacity - buf.tell(),
)
===========unchanged ref 0===========
at: aioquic.buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic.buffer.Buffer
tell() -> int
pull_bytes(length: int) -> bytes
pull_uint_var() -> int
at: aioquic.packet
PACKET_FIXED_BIT = 0x40
PACKET_TYPE_INITIAL = PACKET_LONG_HEADER | PACKET_FIXED_BIT | 0x00
PACKET_TYPE_RETRY = PACKET_LONG_HEADER | PACKET_FIXED_BIT | 0x30
PACKET_TYPE_MASK = 0xF0
QuicProtocolVersion(x: Union[str, bytes, bytearray], base: int)
QuicProtocolVersion(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
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)
decode_cid_length(length: int) -> int
at: aioquic.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.packet.pull_quic_header
first_byte = buf.pull_uint8()
version = buf.pull_uint32()
cid_lengths = buf.pull_uint8()
===========changed ref 0===========
# module: aioquic.buffer
class Buffer:
+ def pull_bytes(self, length: int) -> bytes:
+ """
+ Pull bytes.
+ """
+ end = self._pos + length
+ if end > self._length:
+ raise BufferReadError
+ v = bytes(self._data[self._pos : end])
+ self._pos = end
+ return v
+
===========changed ref 1===========
# module: aioquic.buffer
class Buffer:
+ def pull_uint_var(self) -> int:
+ """
+ Pull a QUIC variable-length unsigned integer.
+ """
+ try:
+ kind = self._data[self._pos] // 64
+ if kind == 0:
+ value = self._data[self._pos]
+ self._pos += 1
+ return value
+ elif kind == 1:
+ value, = unpack_from("!H", self._data, self._pos)
+ self._pos += 2
+ return value & 0x3FFF
+ elif kind == 2:
+ value, = unpack_from("!L", self._data, self._pos)
+ self._pos += 4
+ return value & 0x3FFFFFFF
+ else:
+ value, = unpack_from("!Q", self._data, self._pos)
+ self._pos += 8
+ return value & 0x3FFFFFFFFFFFFFFF
+ except (IndexError, struct.error):
+ raise BufferReadError
+
===========changed ref 2===========
# module: aioquic.tls
def pull_group(buf: Buffer) -> Group:
+ return Group(buf.pull_uint16())
- return Group(pull_uint16(buf))
===========changed ref 3===========
# module: aioquic.tls
def pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm:
+ return SignatureAlgorithm(buf.pull_uint16())
- return SignatureAlgorithm(pull_uint16(buf))
===========changed ref 4===========
# module: aioquic.tls
def pull_compression_method(buf: Buffer) -> CompressionMethod:
+ return CompressionMethod(buf.pull_uint8())
- return CompressionMethod(pull_uint8(buf))
===========changed ref 5===========
# module: aioquic.tls
# INTEGERS
def pull_cipher_suite(buf: Buffer) -> CipherSuite:
+ return CipherSuite(buf.pull_uint16())
- return CipherSuite(pull_uint16(buf))
===========changed ref 6===========
# module: aioquic.tls
def pull_key_exchange_mode(buf: Buffer) -> KeyExchangeMode:
+ return KeyExchangeMode(buf.pull_uint8())
- return KeyExchangeMode(pull_uint8(buf))
===========changed ref 7===========
# module: aioquic.buffer
class Buffer:
+ def push_uint8(self, v: int) -> None:
+ """
+ Push an 8-bit unsigned integer.
+ """
+ self._data[self._pos] = v
+ self._pos += 1
+
===========changed ref 8===========
# module: aioquic.tls
def push_key_share(buf: Buffer, value: KeyShareEntry) -> None:
+ buf.push_uint16(value[0])
- push_group(buf, value[0])
push_opaque(buf, 2, value[1])
===========changed ref 9===========
# module: aioquic.tls
@contextmanager
def push_extension(buf: Buffer, extension_type: int) -> Generator:
+ buf.push_uint16(extension_type)
- push_uint16(buf, extension_type)
with push_block(buf, 2):
yield
===========changed ref 10===========
# module: aioquic.buffer
- def push_uint8(buf: Buffer, v: int) -> None:
- """
- Push an 8-bit unsigned integer.
- """
- buf._data[buf._pos] = v
- buf._pos += 1
-
===========changed ref 11===========
# module: aioquic.tls
def push_psk_identity(buf: Buffer, entry: PskIdentity) -> None:
push_opaque(buf, 2, entry[0])
+ buf.push_uint32(entry[1])
- push_uint32(buf, entry[1])
===========changed ref 12===========
# module: aioquic.buffer
class Buffer:
+ def push_uint64(self, v: int) -> None:
+ """
+ Push a 64-bit unsigned integer.
+ """
+ pack_into("!Q", self._data, self._pos, v)
+ self._pos += 8
+
===========changed ref 13===========
# module: aioquic.buffer
class Buffer:
+ def push_uint32(self, v: int) -> None:
+ """
+ Push a 32-bit unsigned integer.
+ """
+ pack_into("!L", self._data, self._pos, v)
+ self._pos += 4
+
===========changed ref 14===========
# module: aioquic.buffer
class Buffer:
+ def push_uint16(self, v: int) -> None:
+ """
+ Push a 16-bit unsigned integer.
+ """
+ pack_into("!H", self._data, self._pos, v)
+ self._pos += 2
+
|
aioquic.packet/encode_quic_retry
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<7>:<del> push_uint8(
<8>:<add> buf.push_uint8(PACKET_TYPE_RETRY | encode_cid_length(len(original_destination_cid)))
<del> buf, PACKET_TYPE_RETRY | encode_cid_length(len(original_destination_cid))
<9>:<add> buf.push_uint32(version)
<add> buf.push_uint8(
<add> (encode_cid_length(len(destination_cid)) << 4)
<add> | encode_cid_length(len(source_cid))
<10>:<del> push_uint32(buf, version)
<11>:<del> push_uint8(
<12>:<del> buf,
<13>:<del> (encode_cid_length(len(destination_cid)) << 4)
<14>:<del> | encode_cid_length(len(source_cid)),
<15>:<del> )
<16>:<add> buf.push_bytes(destination_cid)
<del> push_bytes(buf, destination_cid)
<17>:<add> buf.push_bytes(source_cid)
<del> push_bytes(buf, source_cid)
<18>:<add> buf.push_bytes(original_destination_cid)
<del> push_bytes(buf, original_destination_cid)
<19>:<add> buf.push_bytes(retry_token)
<del> push_bytes(buf, retry_token)
|
# module: aioquic.packet
def encode_quic_retry(
version: int,
source_cid: bytes,
destination_cid: bytes,
original_destination_cid: bytes,
retry_token: bytes,
) -> bytes:
<0> buf = Buffer(
<1> capacity=6
<2> + len(destination_cid)
<3> + len(source_cid)
<4> + len(original_destination_cid)
<5> + len(retry_token)
<6> )
<7> push_uint8(
<8> buf, PACKET_TYPE_RETRY | encode_cid_length(len(original_destination_cid))
<9> )
<10> push_uint32(buf, version)
<11> push_uint8(
<12> buf,
<13> (encode_cid_length(len(destination_cid)) << 4)
<14> | encode_cid_length(len(source_cid)),
<15> )
<16> push_bytes(buf, destination_cid)
<17> push_bytes(buf, source_cid)
<18> push_bytes(buf, original_destination_cid)
<19> push_bytes(buf, retry_token)
<20> return buf.data
<21>
|
===========unchanged ref 0===========
at: aioquic.buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic.buffer.Buffer
push_bytes(v: bytes) -> None
push_uint8(v: int) -> None
push_uint32(v: int) -> None
at: aioquic.packet
PACKET_LONG_HEADER = 0x80
PACKET_TYPE_RETRY = PACKET_LONG_HEADER | PACKET_FIXED_BIT | 0x30
QuicProtocolVersion(x: Union[str, bytes, bytearray], base: int)
QuicProtocolVersion(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
encode_cid_length(length: int) -> int
at: aioquic.packet.encode_quic_retry
buf = Buffer(
capacity=6
+ len(destination_cid)
+ len(source_cid)
+ len(original_destination_cid)
+ len(retry_token)
)
at: os
urandom(size: int, /) -> bytes
at: typing
List = _alias(list, 1, inst=False, name='List')
===========changed ref 0===========
# module: aioquic.buffer
class Buffer:
+ def push_uint8(self, v: int) -> None:
+ """
+ Push an 8-bit unsigned integer.
+ """
+ self._data[self._pos] = v
+ self._pos += 1
+
===========changed ref 1===========
# module: aioquic.buffer
class Buffer:
+ def push_uint32(self, v: int) -> None:
+ """
+ Push a 32-bit unsigned integer.
+ """
+ pack_into("!L", self._data, self._pos, v)
+ self._pos += 4
+
===========changed ref 2===========
# module: aioquic.buffer
class Buffer:
+ def push_bytes(self, v: bytes) -> None:
+ """
+ Push bytes.
+ """
+ end = self._pos + len(v)
+ if end > self._length:
+ raise BufferWriteError
+ self._data[self._pos : end] = v
+ self._pos = end
+
===========changed ref 3===========
# module: aioquic.packet
def pull_quic_header(buf: Buffer, host_cid_length: Optional[int] = None) -> QuicHeader:
+ first_byte = buf.pull_uint8()
- first_byte = pull_uint8(buf)
original_destination_cid = b""
token = b""
if is_long_header(first_byte):
# long header packet
+ version = buf.pull_uint32()
- version = pull_uint32(buf)
+ cid_lengths = buf.pull_uint8()
- cid_lengths = pull_uint8(buf)
destination_cid_length = decode_cid_length(cid_lengths // 16)
+ destination_cid = buf.pull_bytes(destination_cid_length)
- destination_cid = pull_bytes(buf, destination_cid_length)
source_cid_length = decode_cid_length(cid_lengths % 16)
+ source_cid = buf.pull_bytes(source_cid_length)
- source_cid = pull_bytes(buf, source_cid_length)
if version == QuicProtocolVersion.NEGOTIATION:
# version negotiation
packet_type = None
rest_length = buf.capacity - buf.tell()
else:
if not (first_byte & PACKET_FIXED_BIT):
raise ValueError("Packet fixed bit is zero")
packet_type = first_byte & PACKET_TYPE_MASK
if packet_type == PACKET_TYPE_INITIAL:
+ token_length = buf.pull_uint_var()
- token_length = pull_uint_var(buf)
+ token = buf.pull_bytes(token_length)
- token = pull_bytes(buf, token_length)
+ rest_length = buf.pull_uint_var()
- rest_length = pull_uint_var(buf)
elif packet_type == PACKET_TYPE_RETRY:
original_destination_cid_length = decode_cid_length(first_byte & 0xF)
+ original_</s>
===========changed ref 4===========
# module: aioquic.packet
def pull_quic_header(buf: Buffer, host_cid_length: Optional[int] = None) -> QuicHeader:
# offset: 1
<s>RETRY:
original_destination_cid_length = decode_cid_length(first_byte & 0xF)
+ original_destination_cid = buf.pull_bytes(
- original_destination_cid = pull_bytes(
+ original_destination_cid_length
- buf, original_destination_cid_length
)
+ token = buf.pull_bytes(buf.capacity - buf.tell())
- token = pull_bytes(buf, buf.capacity - buf.tell())
rest_length = 0
else:
+ rest_length = buf.pull_uint_var()
- rest_length = pull_uint_var(buf)
return QuicHeader(
is_long_header=True,
version=version,
packet_type=packet_type,
destination_cid=destination_cid,
source_cid=source_cid,
original_destination_cid=original_destination_cid,
token=token,
rest_length=rest_length,
)
else:
# short header packet
if not (first_byte & PACKET_FIXED_BIT):
raise ValueError("Packet fixed bit is zero")
packet_type = first_byte & PACKET_TYPE_MASK
+ destination_cid = buf.pull_bytes(host_cid_length)
- destination_cid = pull_bytes(buf, host_cid_length)
return QuicHeader(
is_long_header=False,
version=None,
packet_type=packet_type,
destination_cid=destination_cid,
source_cid=b"",
token=b"",
rest_length=buf.capacity - buf.tell(),
)
===========changed ref 5===========
# module: aioquic.tls
def pull_group(buf: Buffer) -> Group:
+ return Group(buf.pull_uint16())
- return Group(pull_uint16(buf))
===========changed ref 6===========
# module: aioquic.tls
def pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm:
+ return SignatureAlgorithm(buf.pull_uint16())
- return SignatureAlgorithm(pull_uint16(buf))
===========changed ref 7===========
# module: aioquic.tls
def pull_compression_method(buf: Buffer) -> CompressionMethod:
+ return CompressionMethod(buf.pull_uint8())
- return CompressionMethod(pull_uint8(buf))
===========changed ref 8===========
# module: aioquic.tls
# INTEGERS
def pull_cipher_suite(buf: Buffer) -> CipherSuite:
+ return CipherSuite(buf.pull_uint16())
- return CipherSuite(pull_uint16(buf))
===========changed ref 9===========
# module: aioquic.tls
def pull_key_exchange_mode(buf: Buffer) -> KeyExchangeMode:
+ return KeyExchangeMode(buf.pull_uint8())
- return KeyExchangeMode(pull_uint8(buf))
===========changed ref 10===========
# module: aioquic.tls
def push_key_share(buf: Buffer, value: KeyShareEntry) -> None:
+ buf.push_uint16(value[0])
- push_group(buf, value[0])
push_opaque(buf, 2, value[1])
===========changed ref 11===========
# module: aioquic.tls
@contextmanager
def push_extension(buf: Buffer, extension_type: int) -> Generator:
+ buf.push_uint16(extension_type)
- push_uint16(buf, extension_type)
with push_block(buf, 2):
yield
|
aioquic.packet/encode_quic_version_negotiation
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<6>:<add> buf.push_uint8(os.urandom(1)[0] | PACKET_LONG_HEADER)
<del> push_uint8(buf, os.urandom(1)[0] | PACKET_LONG_HEADER)
<7>:<add> buf.push_uint32(QuicProtocolVersion.NEGOTIATION)
<del> push_uint32(buf, QuicProtocolVersion.NEGOTIATION)
<8>:<add> buf.push_uint8(
<del> push_uint8(
<9>:<del> buf,
<11>:<add> | encode_cid_length(len(source_cid))
<del> | encode_cid_length(len(source_cid)),
<13>:<add> buf.push_bytes(destination_cid)
<del> push_bytes(buf, destination_cid)
<14>:<add> buf.push_bytes(source_cid)
<del> push_bytes(buf, source_cid)
<16>:<add> buf.push_uint32(version)
<del> push_uint32(buf, version)
|
# module: aioquic.packet
def encode_quic_version_negotiation(
source_cid: bytes,
destination_cid: bytes,
supported_versions: List[QuicProtocolVersion],
) -> bytes:
<0> buf = Buffer(
<1> capacity=6
<2> + len(destination_cid)
<3> + len(source_cid)
<4> + 4 * len(supported_versions)
<5> )
<6> push_uint8(buf, os.urandom(1)[0] | PACKET_LONG_HEADER)
<7> push_uint32(buf, QuicProtocolVersion.NEGOTIATION)
<8> push_uint8(
<9> buf,
<10> (encode_cid_length(len(destination_cid)) << 4)
<11> | encode_cid_length(len(source_cid)),
<12> )
<13> push_bytes(buf, destination_cid)
<14> push_bytes(buf, source_cid)
<15> for version in supported_versions:
<16> push_uint32(buf, version)
<17> return buf.data
<18>
|
===========unchanged ref 0===========
at: aioquic.buffer.Buffer
push_bytes(v: bytes) -> None
push_uint32(v: int) -> None
at: aioquic.packet
QuicProtocolVersion(x: Union[str, bytes, bytearray], base: int)
QuicProtocolVersion(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
encode_cid_length(length: int) -> int
at: aioquic.packet.QuicTransportParameters
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[bytes] = None
at: aioquic.packet.encode_quic_version_negotiation
buf = Buffer(
capacity=6
+ len(destination_cid)
+ len(source_cid)
+ 4 * len(supported_versions)
)
at: dataclasses
field(*, default_factory: Callable[[], _T], init: bool=..., repr: bool=..., hash: Optional[bool]=..., compare: bool=..., metadata: Optional[Mapping[str, Any]]=...) -> _T
field(*, init: bool=..., repr: bool=..., hash: Optional[bool]=..., compare: bool=..., metadata: Optional[Mapping[str, Any]]=...) -> Any
field(*, default: _T, init: bool=..., repr: bool=..., hash: Optional[bool]=..., compare: bool=..., metadata: Optional[Mapping[str, Any]]=...) -> _T
===========unchanged ref 1===========
dataclass(*, init: bool=..., repr: bool=..., eq: bool=..., order: bool=..., unsafe_hash: bool=..., frozen: bool=...) -> Callable[[Type[_T]], Type[_T]]
dataclass(_cls: None) -> Callable[[Type[_T]], Type[_T]]
dataclass(_cls: Type[_T]) -> Type[_T]
at: typing
List = _alias(list, 1, inst=False, name='List')
===========changed ref 0===========
# module: aioquic.buffer
class Buffer:
+ def push_uint32(self, v: int) -> None:
+ """
+ Push a 32-bit unsigned integer.
+ """
+ pack_into("!L", self._data, self._pos, v)
+ self._pos += 4
+
===========changed ref 1===========
# module: aioquic.buffer
class Buffer:
+ def push_bytes(self, v: bytes) -> None:
+ """
+ Push bytes.
+ """
+ end = self._pos + len(v)
+ if end > self._length:
+ raise BufferWriteError
+ self._data[self._pos : end] = v
+ self._pos = end
+
===========changed ref 2===========
# module: aioquic.packet
def encode_quic_retry(
version: int,
source_cid: bytes,
destination_cid: bytes,
original_destination_cid: bytes,
retry_token: bytes,
) -> bytes:
buf = Buffer(
capacity=6
+ len(destination_cid)
+ len(source_cid)
+ len(original_destination_cid)
+ len(retry_token)
)
- push_uint8(
+ buf.push_uint8(PACKET_TYPE_RETRY | encode_cid_length(len(original_destination_cid)))
- buf, PACKET_TYPE_RETRY | encode_cid_length(len(original_destination_cid))
+ buf.push_uint32(version)
+ buf.push_uint8(
+ (encode_cid_length(len(destination_cid)) << 4)
+ | encode_cid_length(len(source_cid))
)
- push_uint32(buf, version)
- push_uint8(
- buf,
- (encode_cid_length(len(destination_cid)) << 4)
- | encode_cid_length(len(source_cid)),
- )
+ buf.push_bytes(destination_cid)
- push_bytes(buf, destination_cid)
+ buf.push_bytes(source_cid)
- push_bytes(buf, source_cid)
+ buf.push_bytes(original_destination_cid)
- push_bytes(buf, original_destination_cid)
+ buf.push_bytes(retry_token)
- push_bytes(buf, retry_token)
return buf.data
===========changed ref 3===========
# module: aioquic.packet
def pull_quic_header(buf: Buffer, host_cid_length: Optional[int] = None) -> QuicHeader:
+ first_byte = buf.pull_uint8()
- first_byte = pull_uint8(buf)
original_destination_cid = b""
token = b""
if is_long_header(first_byte):
# long header packet
+ version = buf.pull_uint32()
- version = pull_uint32(buf)
+ cid_lengths = buf.pull_uint8()
- cid_lengths = pull_uint8(buf)
destination_cid_length = decode_cid_length(cid_lengths // 16)
+ destination_cid = buf.pull_bytes(destination_cid_length)
- destination_cid = pull_bytes(buf, destination_cid_length)
source_cid_length = decode_cid_length(cid_lengths % 16)
+ source_cid = buf.pull_bytes(source_cid_length)
- source_cid = pull_bytes(buf, source_cid_length)
if version == QuicProtocolVersion.NEGOTIATION:
# version negotiation
packet_type = None
rest_length = buf.capacity - buf.tell()
else:
if not (first_byte & PACKET_FIXED_BIT):
raise ValueError("Packet fixed bit is zero")
packet_type = first_byte & PACKET_TYPE_MASK
if packet_type == PACKET_TYPE_INITIAL:
+ token_length = buf.pull_uint_var()
- token_length = pull_uint_var(buf)
+ token = buf.pull_bytes(token_length)
- token = pull_bytes(buf, token_length)
+ rest_length = buf.pull_uint_var()
- rest_length = pull_uint_var(buf)
elif packet_type == PACKET_TYPE_RETRY:
original_destination_cid_length = decode_cid_length(first_byte & 0xF)
+ original_</s>
|
aioquic.packet/pull_quic_transport_parameters
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<5>:<add> param_id = buf.pull_uint16()
<del> param_id = pull_uint16(buf)
<6>:<add> param_len = buf.pull_uint16()
<del> param_len = pull_uint16(buf)
<12>:<add> setattr(params, param_name, buf.pull_uint_var())
<del> setattr(params, param_name, pull_uint_var(buf))
<14>:<add> setattr(params, param_name, buf.pull_bytes(param_len))
<del> setattr(params, param_name, pull_bytes(buf, param_len))
<19>:<add> buf.pull_bytes(param_len)
<del> pull_bytes(buf, param_len)
|
# module: aioquic.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 = pull_uint16(buf)
<6> param_len = pull_uint16(buf)
<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, pull_uint_var(buf))
<13> elif param_type == bytes:
<14> setattr(params, param_name, pull_bytes(buf, param_len))
<15> else:
<16> setattr(params, param_name, True)
<17> else:
<18> # skip unknown parameter
<19> pull_bytes(buf, 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
tell() -> int
pull_bytes(length: int) -> bytes
push_bytes(v: bytes) -> None
push_uint16(v: int) -> None
push_uint_var(value: int) -> None
at: aioquic.packet
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[bytes]=None)
===========unchanged ref 1===========
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", bytes),
]
at: aioquic.packet.pull_quic_transport_parameters
params = QuicTransportParameters()
param_len = buf.pull_uint16()
param_start = buf.tell()
param_name, param_type = PARAMS[param_id]
at: aioquic.tls
push_block(buf: Buffer, capacity: int) -> Generator
===========changed ref 0===========
# module: aioquic.buffer
class Buffer:
+ def push_uint16(self, v: int) -> None:
+ """
+ Push a 16-bit unsigned integer.
+ """
+ pack_into("!H", self._data, self._pos, v)
+ self._pos += 2
+
===========changed ref 1===========
# module: aioquic.buffer
class Buffer:
+ def push_bytes(self, v: bytes) -> None:
+ """
+ Push bytes.
+ """
+ end = self._pos + len(v)
+ if end > self._length:
+ raise BufferWriteError
+ self._data[self._pos : end] = v
+ self._pos = end
+
===========changed ref 2===========
# module: aioquic.buffer
class Buffer:
+ def pull_bytes(self, length: int) -> bytes:
+ """
+ Pull bytes.
+ """
+ end = self._pos + length
+ if end > self._length:
+ raise BufferReadError
+ v = bytes(self._data[self._pos : end])
+ self._pos = end
+ return v
+
===========changed ref 3===========
# module: aioquic.tls
@contextmanager
def push_block(buf: Buffer, capacity: int) -> Generator:
"""
Context manager to push a variable-length block, with `capacity` bytes
to write the length.
"""
+ start = buf.tell() + capacity
+ buf.seek(start)
- buf._pos += capacity
- start = buf._pos
yield
+ end = buf.tell()
+ length = end - start
- length = buf._pos - start
while capacity:
+ buf.seek(start - capacity)
+ buf.push_uint8((length >> (8 * (capacity - 1))) & 0xFF)
- buf._data[start - capacity] = (length >> (8 * (capacity - 1))) & 0xFF
capacity -= 1
+ buf.seek(end)
===========changed ref 4===========
# module: aioquic.buffer
class Buffer:
+ def push_uint_var(self, value: int) -> None:
+ """
+ Push a QUIC variable-length unsigned integer.
+ """
+ if value <= 0x3F:
+ self._data[self._pos] = value
+ self._pos += 1
+ elif value <= 0x3FFF:
+ pack_into("!H", self._data, self._pos, value | 0x4000)
+ self._pos += 2
+ elif value <= 0x3FFFFFFF:
+ pack_into("!L", self._data, self._pos, value | 0x80000000)
+ self._pos += 4
+ elif value <= 0x3FFFFFFFFFFFFFFF:
+ pack_into("!Q", self._data, self._pos, value | 0xC000000000000000)
+ self._pos += 8
+ else:
+ raise ValueError("Integer is too big for a variable-length integer")
+
===========changed ref 5===========
# module: aioquic.packet
def encode_quic_version_negotiation(
source_cid: bytes,
destination_cid: bytes,
supported_versions: List[QuicProtocolVersion],
) -> bytes:
buf = Buffer(
capacity=6
+ len(destination_cid)
+ len(source_cid)
+ 4 * len(supported_versions)
)
+ buf.push_uint8(os.urandom(1)[0] | PACKET_LONG_HEADER)
- push_uint8(buf, os.urandom(1)[0] | PACKET_LONG_HEADER)
+ buf.push_uint32(QuicProtocolVersion.NEGOTIATION)
- push_uint32(buf, QuicProtocolVersion.NEGOTIATION)
+ buf.push_uint8(
- push_uint8(
- buf,
(encode_cid_length(len(destination_cid)) << 4)
+ | encode_cid_length(len(source_cid))
- | encode_cid_length(len(source_cid)),
)
+ buf.push_bytes(destination_cid)
- push_bytes(buf, destination_cid)
+ buf.push_bytes(source_cid)
- push_bytes(buf, source_cid)
for version in supported_versions:
+ buf.push_uint32(version)
- push_uint32(buf, version)
return buf.data
|
aioquic.packet/push_quic_transport_parameters
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<4>:<add> buf.push_uint16(param_id)
<del> push_uint16(buf, param_id)
<7>:<add> buf.push_uint_var(param_value)
<del> push_uint_var(buf, param_value)
<9>:<add> buf.push_bytes(param_value)
<del> push_bytes(buf, param_value)
|
# module: aioquic.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> push_uint16(buf, param_id)
<5> with push_block(buf, 2):
<6> if param_type == int:
<7> push_uint_var(buf, param_value)
<8> elif param_type == bytes:
<9> push_bytes(buf, param_value)
<10>
|
===========unchanged ref 0===========
at: aioquic.packet.QuicFrameType
MAX_STREAM_DATA = 0x11
MAX_STREAMS_BIDI = 0x12
MAX_STREAMS_UNI = 0x13
DATA_BLOCKED = 0x14
STREAM_DATA_BLOCKED = 0x15
STREAMS_BLOCKED_BIDI = 0x16
STREAMS_BLOCKED_UNI = 0x17
NEW_CONNECTION_ID = 0x18
RETIRE_CONNECTION_ID = 0x19
PATH_CHALLENGE = 0x1A
PATH_RESPONSE = 0x1B
TRANSPORT_CLOSE = 0x1C
APPLICATION_CLOSE = 0x1D
at: enum
IntEnum(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
IntEnum(x: Union[str, bytes, bytearray], base: int)
===========changed ref 0===========
# module: aioquic.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_id = pull_uint16(buf)
+ param_len = buf.pull_uint16()
- param_len = pull_uint16(buf)
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())
- setattr(params, param_name, pull_uint_var(buf))
elif param_type == bytes:
+ setattr(params, param_name, buf.pull_bytes(param_len))
- setattr(params, param_name, pull_bytes(buf, param_len))
else:
setattr(params, param_name, True)
else:
# skip unknown parameter
+ buf.pull_bytes(param_len)
- pull_bytes(buf, param_len)
assert buf.tell() == param_start + param_len
return params
===========changed ref 1===========
# module: aioquic.packet
def encode_quic_version_negotiation(
source_cid: bytes,
destination_cid: bytes,
supported_versions: List[QuicProtocolVersion],
) -> bytes:
buf = Buffer(
capacity=6
+ len(destination_cid)
+ len(source_cid)
+ 4 * len(supported_versions)
)
+ buf.push_uint8(os.urandom(1)[0] | PACKET_LONG_HEADER)
- push_uint8(buf, os.urandom(1)[0] | PACKET_LONG_HEADER)
+ buf.push_uint32(QuicProtocolVersion.NEGOTIATION)
- push_uint32(buf, QuicProtocolVersion.NEGOTIATION)
+ buf.push_uint8(
- push_uint8(
- buf,
(encode_cid_length(len(destination_cid)) << 4)
+ | encode_cid_length(len(source_cid))
- | encode_cid_length(len(source_cid)),
)
+ buf.push_bytes(destination_cid)
- push_bytes(buf, destination_cid)
+ buf.push_bytes(source_cid)
- push_bytes(buf, source_cid)
for version in supported_versions:
+ buf.push_uint32(version)
- push_uint32(buf, version)
return buf.data
===========changed ref 2===========
# module: aioquic.packet
def encode_quic_retry(
version: int,
source_cid: bytes,
destination_cid: bytes,
original_destination_cid: bytes,
retry_token: bytes,
) -> bytes:
buf = Buffer(
capacity=6
+ len(destination_cid)
+ len(source_cid)
+ len(original_destination_cid)
+ len(retry_token)
)
- push_uint8(
+ buf.push_uint8(PACKET_TYPE_RETRY | encode_cid_length(len(original_destination_cid)))
- buf, PACKET_TYPE_RETRY | encode_cid_length(len(original_destination_cid))
+ buf.push_uint32(version)
+ buf.push_uint8(
+ (encode_cid_length(len(destination_cid)) << 4)
+ | encode_cid_length(len(source_cid))
)
- push_uint32(buf, version)
- push_uint8(
- buf,
- (encode_cid_length(len(destination_cid)) << 4)
- | encode_cid_length(len(source_cid)),
- )
+ buf.push_bytes(destination_cid)
- push_bytes(buf, destination_cid)
+ buf.push_bytes(source_cid)
- push_bytes(buf, source_cid)
+ buf.push_bytes(original_destination_cid)
- push_bytes(buf, original_destination_cid)
+ buf.push_bytes(retry_token)
- push_bytes(buf, retry_token)
return buf.data
===========changed ref 3===========
# module: aioquic.packet
def pull_quic_header(buf: Buffer, host_cid_length: Optional[int] = None) -> QuicHeader:
+ first_byte = buf.pull_uint8()
- first_byte = pull_uint8(buf)
original_destination_cid = b""
token = b""
if is_long_header(first_byte):
# long header packet
+ version = buf.pull_uint32()
- version = pull_uint32(buf)
+ cid_lengths = buf.pull_uint8()
- cid_lengths = pull_uint8(buf)
destination_cid_length = decode_cid_length(cid_lengths // 16)
+ destination_cid = buf.pull_bytes(destination_cid_length)
- destination_cid = pull_bytes(buf, destination_cid_length)
source_cid_length = decode_cid_length(cid_lengths % 16)
+ source_cid = buf.pull_bytes(source_cid_length)
- source_cid = pull_bytes(buf, source_cid_length)
if version == QuicProtocolVersion.NEGOTIATION:
# version negotiation
packet_type = None
rest_length = buf.capacity - buf.tell()
else:
if not (first_byte & PACKET_FIXED_BIT):
raise ValueError("Packet fixed bit is zero")
packet_type = first_byte & PACKET_TYPE_MASK
if packet_type == PACKET_TYPE_INITIAL:
+ token_length = buf.pull_uint_var()
- token_length = pull_uint_var(buf)
+ token = buf.pull_bytes(token_length)
- token = pull_bytes(buf, token_length)
+ rest_length = buf.pull_uint_var()
- rest_length = pull_uint_var(buf)
elif packet_type == PACKET_TYPE_RETRY:
original_destination_cid_length = decode_cid_length(first_byte & 0xF)
+ original_</s>
|
aioquic.packet/pull_ack_frame
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<1>:<add> end = buf.pull_uint_var() # largest acknowledged
<del> end = pull_uint_var(buf) # largest acknowledged
<2>:<add> delay = buf.pull_uint_var()
<del> delay = pull_uint_var(buf)
<3>:<add> ack_range_count = buf.pull_uint_var()
<del> ack_range_count = pull_uint_var(buf)
<4>:<add> ack_count = buf.pull_uint_var() # first ack range
<del> ack_count = pull_uint_var(buf) # first ack range
<8>:<add> end -= buf.pull_uint_var() + 2
<del> end -= pull_uint_var(buf) + 2
<9>:<add> ack_count = buf.pull_uint_var()
<del> ack_count = pull_uint_var(buf)
|
# module: aioquic.packet
def pull_ack_frame(buf: Buffer) -> Tuple[RangeSet, int]:
<0> rangeset = RangeSet()
<1> end = pull_uint_var(buf) # largest acknowledged
<2> delay = pull_uint_var(buf)
<3> ack_range_count = pull_uint_var(buf)
<4> ack_count = pull_uint_var(buf) # first ack range
<5> rangeset.add(end - ack_count, end + 1)
<6> end -= ack_count
<7> for _ in range(ack_range_count):
<8> end -= pull_uint_var(buf) + 2
<9> ack_count = pull_uint_var(buf)
<10> rangeset.add(end - ack_count, end + 1)
<11> end -= ack_count
<12> return rangeset, delay
<13>
|
===========unchanged ref 0===========
at: aioquic.buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic.buffer.Buffer
push_uint_var(value: int) -> None
at: aioquic.rangeset
RangeSet(ranges: Iterable[range]=[])
===========changed ref 0===========
# module: aioquic.buffer
class Buffer:
+ def push_uint_var(self, value: int) -> None:
+ """
+ Push a QUIC variable-length unsigned integer.
+ """
+ if value <= 0x3F:
+ self._data[self._pos] = value
+ self._pos += 1
+ elif value <= 0x3FFF:
+ pack_into("!H", self._data, self._pos, value | 0x4000)
+ self._pos += 2
+ elif value <= 0x3FFFFFFF:
+ pack_into("!L", self._data, self._pos, value | 0x80000000)
+ self._pos += 4
+ elif value <= 0x3FFFFFFFFFFFFFFF:
+ pack_into("!Q", self._data, self._pos, value | 0xC000000000000000)
+ self._pos += 8
+ else:
+ raise ValueError("Integer is too big for a variable-length integer")
+
===========changed ref 1===========
# module: aioquic.packet
def push_quic_transport_parameters(
buf: Buffer, params: QuicTransportParameters
) -> None:
with push_block(buf, 2):
for param_id, (param_name, param_type) in enumerate(PARAMS):
param_value = getattr(params, param_name)
if param_value is not None and param_value is not False:
+ buf.push_uint16(param_id)
- push_uint16(buf, param_id)
with push_block(buf, 2):
if param_type == int:
+ buf.push_uint_var(param_value)
- push_uint_var(buf, param_value)
elif param_type == bytes:
+ buf.push_bytes(param_value)
- push_bytes(buf, param_value)
===========changed ref 2===========
# module: aioquic.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_id = pull_uint16(buf)
+ param_len = buf.pull_uint16()
- param_len = pull_uint16(buf)
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())
- setattr(params, param_name, pull_uint_var(buf))
elif param_type == bytes:
+ setattr(params, param_name, buf.pull_bytes(param_len))
- setattr(params, param_name, pull_bytes(buf, param_len))
else:
setattr(params, param_name, True)
else:
# skip unknown parameter
+ buf.pull_bytes(param_len)
- pull_bytes(buf, param_len)
assert buf.tell() == param_start + param_len
return params
===========changed ref 3===========
# module: aioquic.packet
def encode_quic_version_negotiation(
source_cid: bytes,
destination_cid: bytes,
supported_versions: List[QuicProtocolVersion],
) -> bytes:
buf = Buffer(
capacity=6
+ len(destination_cid)
+ len(source_cid)
+ 4 * len(supported_versions)
)
+ buf.push_uint8(os.urandom(1)[0] | PACKET_LONG_HEADER)
- push_uint8(buf, os.urandom(1)[0] | PACKET_LONG_HEADER)
+ buf.push_uint32(QuicProtocolVersion.NEGOTIATION)
- push_uint32(buf, QuicProtocolVersion.NEGOTIATION)
+ buf.push_uint8(
- push_uint8(
- buf,
(encode_cid_length(len(destination_cid)) << 4)
+ | encode_cid_length(len(source_cid))
- | encode_cid_length(len(source_cid)),
)
+ buf.push_bytes(destination_cid)
- push_bytes(buf, destination_cid)
+ buf.push_bytes(source_cid)
- push_bytes(buf, source_cid)
for version in supported_versions:
+ buf.push_uint32(version)
- push_uint32(buf, version)
return buf.data
===========changed ref 4===========
# module: aioquic.packet
def encode_quic_retry(
version: int,
source_cid: bytes,
destination_cid: bytes,
original_destination_cid: bytes,
retry_token: bytes,
) -> bytes:
buf = Buffer(
capacity=6
+ len(destination_cid)
+ len(source_cid)
+ len(original_destination_cid)
+ len(retry_token)
)
- push_uint8(
+ buf.push_uint8(PACKET_TYPE_RETRY | encode_cid_length(len(original_destination_cid)))
- buf, PACKET_TYPE_RETRY | encode_cid_length(len(original_destination_cid))
+ buf.push_uint32(version)
+ buf.push_uint8(
+ (encode_cid_length(len(destination_cid)) << 4)
+ | encode_cid_length(len(source_cid))
)
- push_uint32(buf, version)
- push_uint8(
- buf,
- (encode_cid_length(len(destination_cid)) << 4)
- | encode_cid_length(len(source_cid)),
- )
+ buf.push_bytes(destination_cid)
- push_bytes(buf, destination_cid)
+ buf.push_bytes(source_cid)
- push_bytes(buf, source_cid)
+ buf.push_bytes(original_destination_cid)
- push_bytes(buf, original_destination_cid)
+ buf.push_bytes(retry_token)
- push_bytes(buf, retry_token)
return buf.data
===========changed ref 5===========
# module: aioquic.tls
def pull_group(buf: Buffer) -> Group:
+ return Group(buf.pull_uint16())
- return Group(pull_uint16(buf))
===========changed ref 6===========
# module: aioquic.tls
def pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm:
+ return SignatureAlgorithm(buf.pull_uint16())
- return SignatureAlgorithm(pull_uint16(buf))
===========changed ref 7===========
# module: aioquic.tls
def pull_compression_method(buf: Buffer) -> CompressionMethod:
+ return CompressionMethod(buf.pull_uint8())
- return CompressionMethod(pull_uint8(buf))
===========changed ref 8===========
# module: aioquic.tls
# INTEGERS
def pull_cipher_suite(buf: Buffer) -> CipherSuite:
+ return CipherSuite(buf.pull_uint16())
- return CipherSuite(pull_uint16(buf))
|
aioquic.packet/push_ack_frame
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<2>:<add> buf.push_uint_var(r.stop - 1)
<del> push_uint_var(buf, r.stop - 1)
<3>:<add> buf.push_uint_var(delay)
<del> push_uint_var(buf, delay)
<4>:<add> buf.push_uint_var(index)
<del> push_uint_var(buf, index)
<5>:<add> buf.push_uint_var(r.stop - 1 - r.start)
<del> push_uint_var(buf, r.stop - 1 - r.start)
<10>:<add> buf.push_uint_var(start - r.stop - 1)
<del> push_uint_var(buf, start - r.stop - 1)
<11>:<add> buf.push_uint_var(r.stop - r.start - 1)
<del> push_uint_var(buf, r.stop - r.start - 1)
|
# module: aioquic.packet
def push_ack_frame(buf: Buffer, rangeset: RangeSet, delay: int) -> None:
<0> index = len(rangeset) - 1
<1> r = rangeset[index]
<2> push_uint_var(buf, r.stop - 1)
<3> push_uint_var(buf, delay)
<4> push_uint_var(buf, index)
<5> push_uint_var(buf, r.stop - 1 - r.start)
<6> start = r.start
<7> while index > 0:
<8> index -= 1
<9> r = rangeset[index]
<10> push_uint_var(buf, start - r.stop - 1)
<11> push_uint_var(buf, r.stop - r.start - 1)
<12> start = r.start
<13>
|
===========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_uint_var() -> int
at: dataclasses
dataclass(*, init: bool=..., repr: bool=..., eq: bool=..., order: bool=..., unsafe_hash: bool=..., frozen: bool=...) -> Callable[[Type[_T]], Type[_T]]
dataclass(_cls: None) -> Callable[[Type[_T]], Type[_T]]
dataclass(_cls: Type[_T]) -> Type[_T]
===========changed ref 0===========
# module: aioquic.buffer
class Buffer:
+ def pull_bytes(self, length: int) -> bytes:
+ """
+ Pull bytes.
+ """
+ end = self._pos + length
+ if end > self._length:
+ raise BufferReadError
+ v = bytes(self._data[self._pos : end])
+ self._pos = end
+ return v
+
===========changed ref 1===========
# module: aioquic.buffer
class Buffer:
+ def pull_uint_var(self) -> int:
+ """
+ Pull a QUIC variable-length unsigned integer.
+ """
+ try:
+ kind = self._data[self._pos] // 64
+ if kind == 0:
+ value = self._data[self._pos]
+ self._pos += 1
+ return value
+ elif kind == 1:
+ value, = unpack_from("!H", self._data, self._pos)
+ self._pos += 2
+ return value & 0x3FFF
+ elif kind == 2:
+ value, = unpack_from("!L", self._data, self._pos)
+ self._pos += 4
+ return value & 0x3FFFFFFF
+ else:
+ value, = unpack_from("!Q", self._data, self._pos)
+ self._pos += 8
+ return value & 0x3FFFFFFFFFFFFFFF
+ except (IndexError, struct.error):
+ raise BufferReadError
+
===========changed ref 2===========
# module: aioquic.packet
def push_quic_transport_parameters(
buf: Buffer, params: QuicTransportParameters
) -> None:
with push_block(buf, 2):
for param_id, (param_name, param_type) in enumerate(PARAMS):
param_value = getattr(params, param_name)
if param_value is not None and param_value is not False:
+ buf.push_uint16(param_id)
- push_uint16(buf, param_id)
with push_block(buf, 2):
if param_type == int:
+ buf.push_uint_var(param_value)
- push_uint_var(buf, param_value)
elif param_type == bytes:
+ buf.push_bytes(param_value)
- push_bytes(buf, param_value)
===========changed ref 3===========
# module: aioquic.packet
def pull_ack_frame(buf: Buffer) -> Tuple[RangeSet, int]:
rangeset = RangeSet()
+ end = buf.pull_uint_var() # largest acknowledged
- end = pull_uint_var(buf) # largest acknowledged
+ delay = buf.pull_uint_var()
- delay = pull_uint_var(buf)
+ ack_range_count = buf.pull_uint_var()
- ack_range_count = pull_uint_var(buf)
+ ack_count = buf.pull_uint_var() # first ack range
- ack_count = pull_uint_var(buf) # first ack range
rangeset.add(end - ack_count, end + 1)
end -= ack_count
for _ in range(ack_range_count):
+ end -= buf.pull_uint_var() + 2
- end -= pull_uint_var(buf) + 2
+ ack_count = buf.pull_uint_var()
- ack_count = pull_uint_var(buf)
rangeset.add(end - ack_count, end + 1)
end -= ack_count
return rangeset, delay
===========changed ref 4===========
# module: aioquic.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_id = pull_uint16(buf)
+ param_len = buf.pull_uint16()
- param_len = pull_uint16(buf)
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())
- setattr(params, param_name, pull_uint_var(buf))
elif param_type == bytes:
+ setattr(params, param_name, buf.pull_bytes(param_len))
- setattr(params, param_name, pull_bytes(buf, param_len))
else:
setattr(params, param_name, True)
else:
# skip unknown parameter
+ buf.pull_bytes(param_len)
- pull_bytes(buf, param_len)
assert buf.tell() == param_start + param_len
return params
===========changed ref 5===========
# module: aioquic.packet
def encode_quic_version_negotiation(
source_cid: bytes,
destination_cid: bytes,
supported_versions: List[QuicProtocolVersion],
) -> bytes:
buf = Buffer(
capacity=6
+ len(destination_cid)
+ len(source_cid)
+ 4 * len(supported_versions)
)
+ buf.push_uint8(os.urandom(1)[0] | PACKET_LONG_HEADER)
- push_uint8(buf, os.urandom(1)[0] | PACKET_LONG_HEADER)
+ buf.push_uint32(QuicProtocolVersion.NEGOTIATION)
- push_uint32(buf, QuicProtocolVersion.NEGOTIATION)
+ buf.push_uint8(
- push_uint8(
- buf,
(encode_cid_length(len(destination_cid)) << 4)
+ | encode_cid_length(len(source_cid))
- | encode_cid_length(len(source_cid)),
)
+ buf.push_bytes(destination_cid)
- push_bytes(buf, destination_cid)
+ buf.push_bytes(source_cid)
- push_bytes(buf, source_cid)
for version in supported_versions:
+ buf.push_uint32(version)
- push_uint32(buf, version)
return buf.data
|
aioquic.packet/pull_crypto_frame
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<0>:<add> offset = buf.pull_uint_var()
<del> offset = pull_uint_var(buf)
<1>:<add> length = buf.pull_uint_var()
<del> length = pull_uint_var(buf)
<2>:<add> return QuicStreamFrame(offset=offset, data=buf.pull_bytes(length))
<del> return QuicStreamFrame(offset=offset, data=pull_bytes(buf, length))
|
# module: aioquic.packet
def pull_crypto_frame(buf: Buffer) -> QuicStreamFrame:
<0> offset = pull_uint_var(buf)
<1> length = pull_uint_var(buf)
<2> return QuicStreamFrame(offset=offset, data=pull_bytes(buf, length))
<3>
|
===========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_uint_var() -> int
at: typing
Tuple = _TupleType(tuple, -1, inst=False, name='Tuple')
===========changed ref 0===========
# module: aioquic.buffer
class Buffer:
+ def pull_uint8(self) -> int:
+ """
+ Pull an 8-bit unsigned integer.
+ """
+ try:
+ v = self._data[self._pos]
+ self._pos += 1
+ return v
+ except IndexError:
+ raise BufferReadError
+
===========changed ref 1===========
# module: aioquic.buffer
class Buffer:
+ def pull_bytes(self, length: int) -> bytes:
+ """
+ Pull bytes.
+ """
+ end = self._pos + length
+ if end > self._length:
+ raise BufferReadError
+ v = bytes(self._data[self._pos : end])
+ self._pos = end
+ return v
+
===========changed ref 2===========
# module: aioquic.buffer
class Buffer:
+ def pull_uint_var(self) -> int:
+ """
+ Pull a QUIC variable-length unsigned integer.
+ """
+ try:
+ kind = self._data[self._pos] // 64
+ if kind == 0:
+ value = self._data[self._pos]
+ self._pos += 1
+ return value
+ elif kind == 1:
+ value, = unpack_from("!H", self._data, self._pos)
+ self._pos += 2
+ return value & 0x3FFF
+ elif kind == 2:
+ value, = unpack_from("!L", self._data, self._pos)
+ self._pos += 4
+ return value & 0x3FFFFFFF
+ else:
+ value, = unpack_from("!Q", self._data, self._pos)
+ self._pos += 8
+ return value & 0x3FFFFFFFFFFFFFFF
+ except (IndexError, struct.error):
+ raise BufferReadError
+
===========changed ref 3===========
# module: aioquic.packet
def push_quic_transport_parameters(
buf: Buffer, params: QuicTransportParameters
) -> None:
with push_block(buf, 2):
for param_id, (param_name, param_type) in enumerate(PARAMS):
param_value = getattr(params, param_name)
if param_value is not None and param_value is not False:
+ buf.push_uint16(param_id)
- push_uint16(buf, param_id)
with push_block(buf, 2):
if param_type == int:
+ buf.push_uint_var(param_value)
- push_uint_var(buf, param_value)
elif param_type == bytes:
+ buf.push_bytes(param_value)
- push_bytes(buf, param_value)
===========changed ref 4===========
# module: aioquic.packet
def push_ack_frame(buf: Buffer, rangeset: RangeSet, delay: int) -> None:
index = len(rangeset) - 1
r = rangeset[index]
+ buf.push_uint_var(r.stop - 1)
- push_uint_var(buf, r.stop - 1)
+ buf.push_uint_var(delay)
- push_uint_var(buf, delay)
+ buf.push_uint_var(index)
- push_uint_var(buf, index)
+ buf.push_uint_var(r.stop - 1 - r.start)
- push_uint_var(buf, r.stop - 1 - r.start)
start = r.start
while index > 0:
index -= 1
r = rangeset[index]
+ buf.push_uint_var(start - r.stop - 1)
- push_uint_var(buf, start - r.stop - 1)
+ buf.push_uint_var(r.stop - r.start - 1)
- push_uint_var(buf, r.stop - r.start - 1)
start = r.start
===========changed ref 5===========
# module: aioquic.packet
def pull_ack_frame(buf: Buffer) -> Tuple[RangeSet, int]:
rangeset = RangeSet()
+ end = buf.pull_uint_var() # largest acknowledged
- end = pull_uint_var(buf) # largest acknowledged
+ delay = buf.pull_uint_var()
- delay = pull_uint_var(buf)
+ ack_range_count = buf.pull_uint_var()
- ack_range_count = pull_uint_var(buf)
+ ack_count = buf.pull_uint_var() # first ack range
- ack_count = pull_uint_var(buf) # first ack range
rangeset.add(end - ack_count, end + 1)
end -= ack_count
for _ in range(ack_range_count):
+ end -= buf.pull_uint_var() + 2
- end -= pull_uint_var(buf) + 2
+ ack_count = buf.pull_uint_var()
- ack_count = pull_uint_var(buf)
rangeset.add(end - ack_count, end + 1)
end -= ack_count
return rangeset, delay
===========changed ref 6===========
# module: aioquic.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_id = pull_uint16(buf)
+ param_len = buf.pull_uint16()
- param_len = pull_uint16(buf)
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())
- setattr(params, param_name, pull_uint_var(buf))
elif param_type == bytes:
+ setattr(params, param_name, buf.pull_bytes(param_len))
- setattr(params, param_name, pull_bytes(buf, param_len))
else:
setattr(params, param_name, True)
else:
# skip unknown parameter
+ buf.pull_bytes(param_len)
- pull_bytes(buf, param_len)
assert buf.tell() == param_start + param_len
return params
|
aioquic.packet/pull_new_token_frame
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<0>:<add> length = buf.pull_uint_var()
<del> length = pull_uint_var(buf)
<1>:<add> return buf.pull_bytes(length)
<del> return pull_bytes(buf, length)
|
# module: aioquic.packet
def pull_new_token_frame(buf: Buffer) -> bytes:
<0> length = pull_uint_var(buf)
<1> return pull_bytes(buf, length)
<2>
|
===========changed ref 0===========
# module: aioquic.packet
def pull_crypto_frame(buf: Buffer) -> QuicStreamFrame:
+ offset = buf.pull_uint_var()
- offset = pull_uint_var(buf)
+ length = buf.pull_uint_var()
- length = pull_uint_var(buf)
+ return QuicStreamFrame(offset=offset, data=buf.pull_bytes(length))
- return QuicStreamFrame(offset=offset, data=pull_bytes(buf, length))
===========changed ref 1===========
# module: aioquic.packet
def push_quic_transport_parameters(
buf: Buffer, params: QuicTransportParameters
) -> None:
with push_block(buf, 2):
for param_id, (param_name, param_type) in enumerate(PARAMS):
param_value = getattr(params, param_name)
if param_value is not None and param_value is not False:
+ buf.push_uint16(param_id)
- push_uint16(buf, param_id)
with push_block(buf, 2):
if param_type == int:
+ buf.push_uint_var(param_value)
- push_uint_var(buf, param_value)
elif param_type == bytes:
+ buf.push_bytes(param_value)
- push_bytes(buf, param_value)
===========changed ref 2===========
# module: aioquic.packet
def push_ack_frame(buf: Buffer, rangeset: RangeSet, delay: int) -> None:
index = len(rangeset) - 1
r = rangeset[index]
+ buf.push_uint_var(r.stop - 1)
- push_uint_var(buf, r.stop - 1)
+ buf.push_uint_var(delay)
- push_uint_var(buf, delay)
+ buf.push_uint_var(index)
- push_uint_var(buf, index)
+ buf.push_uint_var(r.stop - 1 - r.start)
- push_uint_var(buf, r.stop - 1 - r.start)
start = r.start
while index > 0:
index -= 1
r = rangeset[index]
+ buf.push_uint_var(start - r.stop - 1)
- push_uint_var(buf, start - r.stop - 1)
+ buf.push_uint_var(r.stop - r.start - 1)
- push_uint_var(buf, r.stop - r.start - 1)
start = r.start
===========changed ref 3===========
# module: aioquic.packet
def pull_ack_frame(buf: Buffer) -> Tuple[RangeSet, int]:
rangeset = RangeSet()
+ end = buf.pull_uint_var() # largest acknowledged
- end = pull_uint_var(buf) # largest acknowledged
+ delay = buf.pull_uint_var()
- delay = pull_uint_var(buf)
+ ack_range_count = buf.pull_uint_var()
- ack_range_count = pull_uint_var(buf)
+ ack_count = buf.pull_uint_var() # first ack range
- ack_count = pull_uint_var(buf) # first ack range
rangeset.add(end - ack_count, end + 1)
end -= ack_count
for _ in range(ack_range_count):
+ end -= buf.pull_uint_var() + 2
- end -= pull_uint_var(buf) + 2
+ ack_count = buf.pull_uint_var()
- ack_count = pull_uint_var(buf)
rangeset.add(end - ack_count, end + 1)
end -= ack_count
return rangeset, delay
===========changed ref 4===========
# module: aioquic.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_id = pull_uint16(buf)
+ param_len = buf.pull_uint16()
- param_len = pull_uint16(buf)
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())
- setattr(params, param_name, pull_uint_var(buf))
elif param_type == bytes:
+ setattr(params, param_name, buf.pull_bytes(param_len))
- setattr(params, param_name, pull_bytes(buf, param_len))
else:
setattr(params, param_name, True)
else:
# skip unknown parameter
+ buf.pull_bytes(param_len)
- pull_bytes(buf, param_len)
assert buf.tell() == param_start + param_len
return params
===========changed ref 5===========
# module: aioquic.packet
def encode_quic_version_negotiation(
source_cid: bytes,
destination_cid: bytes,
supported_versions: List[QuicProtocolVersion],
) -> bytes:
buf = Buffer(
capacity=6
+ len(destination_cid)
+ len(source_cid)
+ 4 * len(supported_versions)
)
+ buf.push_uint8(os.urandom(1)[0] | PACKET_LONG_HEADER)
- push_uint8(buf, os.urandom(1)[0] | PACKET_LONG_HEADER)
+ buf.push_uint32(QuicProtocolVersion.NEGOTIATION)
- push_uint32(buf, QuicProtocolVersion.NEGOTIATION)
+ buf.push_uint8(
- push_uint8(
- buf,
(encode_cid_length(len(destination_cid)) << 4)
+ | encode_cid_length(len(source_cid))
- | encode_cid_length(len(source_cid)),
)
+ buf.push_bytes(destination_cid)
- push_bytes(buf, destination_cid)
+ buf.push_bytes(source_cid)
- push_bytes(buf, source_cid)
for version in supported_versions:
+ buf.push_uint32(version)
- push_uint32(buf, version)
return buf.data
|
aioquic.packet/push_new_token_frame
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<0>:<add> buf.push_uint_var(len(token))
<del> push_uint_var(buf, len(token))
<1>:<add> buf.push_bytes(token)
<del> push_bytes(buf, token)
|
# module: aioquic.packet
def push_new_token_frame(buf: Buffer, token: bytes) -> None:
<0> push_uint_var(buf, len(token))
<1> push_bytes(buf, token)
<2>
|
===========changed ref 0===========
# module: aioquic.packet
def pull_new_token_frame(buf: Buffer) -> bytes:
+ length = buf.pull_uint_var()
- length = pull_uint_var(buf)
+ return buf.pull_bytes(length)
- return pull_bytes(buf, length)
===========changed ref 1===========
# module: aioquic.packet
def pull_crypto_frame(buf: Buffer) -> QuicStreamFrame:
+ offset = buf.pull_uint_var()
- offset = pull_uint_var(buf)
+ length = buf.pull_uint_var()
- length = pull_uint_var(buf)
+ return QuicStreamFrame(offset=offset, data=buf.pull_bytes(length))
- return QuicStreamFrame(offset=offset, data=pull_bytes(buf, length))
===========changed ref 2===========
# module: aioquic.packet
def push_quic_transport_parameters(
buf: Buffer, params: QuicTransportParameters
) -> None:
with push_block(buf, 2):
for param_id, (param_name, param_type) in enumerate(PARAMS):
param_value = getattr(params, param_name)
if param_value is not None and param_value is not False:
+ buf.push_uint16(param_id)
- push_uint16(buf, param_id)
with push_block(buf, 2):
if param_type == int:
+ buf.push_uint_var(param_value)
- push_uint_var(buf, param_value)
elif param_type == bytes:
+ buf.push_bytes(param_value)
- push_bytes(buf, param_value)
===========changed ref 3===========
# module: aioquic.packet
def push_ack_frame(buf: Buffer, rangeset: RangeSet, delay: int) -> None:
index = len(rangeset) - 1
r = rangeset[index]
+ buf.push_uint_var(r.stop - 1)
- push_uint_var(buf, r.stop - 1)
+ buf.push_uint_var(delay)
- push_uint_var(buf, delay)
+ buf.push_uint_var(index)
- push_uint_var(buf, index)
+ buf.push_uint_var(r.stop - 1 - r.start)
- push_uint_var(buf, r.stop - 1 - r.start)
start = r.start
while index > 0:
index -= 1
r = rangeset[index]
+ buf.push_uint_var(start - r.stop - 1)
- push_uint_var(buf, start - r.stop - 1)
+ buf.push_uint_var(r.stop - r.start - 1)
- push_uint_var(buf, r.stop - r.start - 1)
start = r.start
===========changed ref 4===========
# module: aioquic.packet
def pull_ack_frame(buf: Buffer) -> Tuple[RangeSet, int]:
rangeset = RangeSet()
+ end = buf.pull_uint_var() # largest acknowledged
- end = pull_uint_var(buf) # largest acknowledged
+ delay = buf.pull_uint_var()
- delay = pull_uint_var(buf)
+ ack_range_count = buf.pull_uint_var()
- ack_range_count = pull_uint_var(buf)
+ ack_count = buf.pull_uint_var() # first ack range
- ack_count = pull_uint_var(buf) # first ack range
rangeset.add(end - ack_count, end + 1)
end -= ack_count
for _ in range(ack_range_count):
+ end -= buf.pull_uint_var() + 2
- end -= pull_uint_var(buf) + 2
+ ack_count = buf.pull_uint_var()
- ack_count = pull_uint_var(buf)
rangeset.add(end - ack_count, end + 1)
end -= ack_count
return rangeset, delay
===========changed ref 5===========
# module: aioquic.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_id = pull_uint16(buf)
+ param_len = buf.pull_uint16()
- param_len = pull_uint16(buf)
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())
- setattr(params, param_name, pull_uint_var(buf))
elif param_type == bytes:
+ setattr(params, param_name, buf.pull_bytes(param_len))
- setattr(params, param_name, pull_bytes(buf, param_len))
else:
setattr(params, param_name, True)
else:
# skip unknown parameter
+ buf.pull_bytes(param_len)
- pull_bytes(buf, param_len)
assert buf.tell() == param_start + param_len
return params
===========changed ref 6===========
# module: aioquic.packet
def encode_quic_version_negotiation(
source_cid: bytes,
destination_cid: bytes,
supported_versions: List[QuicProtocolVersion],
) -> bytes:
buf = Buffer(
capacity=6
+ len(destination_cid)
+ len(source_cid)
+ 4 * len(supported_versions)
)
+ buf.push_uint8(os.urandom(1)[0] | PACKET_LONG_HEADER)
- push_uint8(buf, os.urandom(1)[0] | PACKET_LONG_HEADER)
+ buf.push_uint32(QuicProtocolVersion.NEGOTIATION)
- push_uint32(buf, QuicProtocolVersion.NEGOTIATION)
+ buf.push_uint8(
- push_uint8(
- buf,
(encode_cid_length(len(destination_cid)) << 4)
+ | encode_cid_length(len(source_cid))
- | encode_cid_length(len(source_cid)),
)
+ buf.push_bytes(destination_cid)
- push_bytes(buf, destination_cid)
+ buf.push_bytes(source_cid)
- push_bytes(buf, source_cid)
for version in supported_versions:
+ buf.push_uint32(version)
- push_uint32(buf, version)
return buf.data
|
aioquic.packet/pull_new_connection_id_frame
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<0>:<add> sequence_number = buf.pull_uint_var()
<del> sequence_number = pull_uint_var(buf)
<1>:<add> length = buf.pull_uint8()
<del> length = pull_uint8(buf)
<2>:<add> connection_id = buf.pull_bytes(length)
<del> connection_id = pull_bytes(buf, length)
<3>:<add> stateless_reset_token = buf.pull_bytes(16)
<del> stateless_reset_token = pull_bytes(buf, 16)
|
# module: aioquic.packet
def pull_new_connection_id_frame(buf: Buffer) -> Tuple[int, bytes, bytes]:
<0> sequence_number = pull_uint_var(buf)
<1> length = pull_uint8(buf)
<2> connection_id = pull_bytes(buf, length)
<3> stateless_reset_token = pull_bytes(buf, 16)
<4> return (sequence_number, connection_id, stateless_reset_token)
<5>
|
===========unchanged ref 0===========
at: aioquic.buffer.Buffer
push_bytes(v: bytes) -> None
push_uint8(v: int) -> None
===========changed ref 0===========
# module: aioquic.buffer
class Buffer:
+ def push_uint8(self, v: int) -> None:
+ """
+ Push an 8-bit unsigned integer.
+ """
+ self._data[self._pos] = v
+ self._pos += 1
+
===========changed ref 1===========
# module: aioquic.buffer
class Buffer:
+ def push_bytes(self, v: bytes) -> None:
+ """
+ Push bytes.
+ """
+ end = self._pos + len(v)
+ if end > self._length:
+ raise BufferWriteError
+ self._data[self._pos : end] = v
+ self._pos = end
+
===========changed ref 2===========
# module: aioquic.packet
def push_new_token_frame(buf: Buffer, token: bytes) -> None:
+ buf.push_uint_var(len(token))
- push_uint_var(buf, len(token))
+ buf.push_bytes(token)
- push_bytes(buf, token)
===========changed ref 3===========
# module: aioquic.packet
def pull_new_token_frame(buf: Buffer) -> bytes:
+ length = buf.pull_uint_var()
- length = pull_uint_var(buf)
+ return buf.pull_bytes(length)
- return pull_bytes(buf, length)
===========changed ref 4===========
# module: aioquic.packet
def pull_crypto_frame(buf: Buffer) -> QuicStreamFrame:
+ offset = buf.pull_uint_var()
- offset = pull_uint_var(buf)
+ length = buf.pull_uint_var()
- length = pull_uint_var(buf)
+ return QuicStreamFrame(offset=offset, data=buf.pull_bytes(length))
- return QuicStreamFrame(offset=offset, data=pull_bytes(buf, length))
===========changed ref 5===========
# module: aioquic.packet
def push_quic_transport_parameters(
buf: Buffer, params: QuicTransportParameters
) -> None:
with push_block(buf, 2):
for param_id, (param_name, param_type) in enumerate(PARAMS):
param_value = getattr(params, param_name)
if param_value is not None and param_value is not False:
+ buf.push_uint16(param_id)
- push_uint16(buf, param_id)
with push_block(buf, 2):
if param_type == int:
+ buf.push_uint_var(param_value)
- push_uint_var(buf, param_value)
elif param_type == bytes:
+ buf.push_bytes(param_value)
- push_bytes(buf, param_value)
===========changed ref 6===========
# module: aioquic.packet
def push_ack_frame(buf: Buffer, rangeset: RangeSet, delay: int) -> None:
index = len(rangeset) - 1
r = rangeset[index]
+ buf.push_uint_var(r.stop - 1)
- push_uint_var(buf, r.stop - 1)
+ buf.push_uint_var(delay)
- push_uint_var(buf, delay)
+ buf.push_uint_var(index)
- push_uint_var(buf, index)
+ buf.push_uint_var(r.stop - 1 - r.start)
- push_uint_var(buf, r.stop - 1 - r.start)
start = r.start
while index > 0:
index -= 1
r = rangeset[index]
+ buf.push_uint_var(start - r.stop - 1)
- push_uint_var(buf, start - r.stop - 1)
+ buf.push_uint_var(r.stop - r.start - 1)
- push_uint_var(buf, r.stop - r.start - 1)
start = r.start
===========changed ref 7===========
# module: aioquic.packet
def pull_ack_frame(buf: Buffer) -> Tuple[RangeSet, int]:
rangeset = RangeSet()
+ end = buf.pull_uint_var() # largest acknowledged
- end = pull_uint_var(buf) # largest acknowledged
+ delay = buf.pull_uint_var()
- delay = pull_uint_var(buf)
+ ack_range_count = buf.pull_uint_var()
- ack_range_count = pull_uint_var(buf)
+ ack_count = buf.pull_uint_var() # first ack range
- ack_count = pull_uint_var(buf) # first ack range
rangeset.add(end - ack_count, end + 1)
end -= ack_count
for _ in range(ack_range_count):
+ end -= buf.pull_uint_var() + 2
- end -= pull_uint_var(buf) + 2
+ ack_count = buf.pull_uint_var()
- ack_count = pull_uint_var(buf)
rangeset.add(end - ack_count, end + 1)
end -= ack_count
return rangeset, delay
===========changed ref 8===========
# module: aioquic.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_id = pull_uint16(buf)
+ param_len = buf.pull_uint16()
- param_len = pull_uint16(buf)
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())
- setattr(params, param_name, pull_uint_var(buf))
elif param_type == bytes:
+ setattr(params, param_name, buf.pull_bytes(param_len))
- setattr(params, param_name, pull_bytes(buf, param_len))
else:
setattr(params, param_name, True)
else:
# skip unknown parameter
+ buf.pull_bytes(param_len)
- pull_bytes(buf, param_len)
assert buf.tell() == param_start + param_len
return params
|
aioquic.packet/push_new_connection_id_frame
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<1>:<add> buf.push_uint_var(sequence_number)
<del> push_uint_var(buf, sequence_number)
<2>:<add> buf.push_uint8(len(connection_id))
<del> push_uint8(buf, len(connection_id))
<3>:<add> buf.push_bytes(connection_id)
<del> push_bytes(buf, connection_id)
<4>:<add> buf.push_bytes(stateless_reset_token)
<del> push_bytes(buf, stateless_reset_token)
|
# module: aioquic.packet
def push_new_connection_id_frame(
buf: Buffer,
sequence_number: int,
connection_id: bytes,
stateless_reset_token: bytes,
) -> None:
<0> assert len(stateless_reset_token) == 16
<1> push_uint_var(buf, sequence_number)
<2> push_uint8(buf, len(connection_id))
<3> push_bytes(buf, connection_id)
<4> push_bytes(buf, stateless_reset_token)
<5>
|
===========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_uint16() -> int
pull_uint_var() -> int
at: aioquic.packet
decode_reason_phrase(reason_bytes: bytes) -> str
at: typing
Tuple = _TupleType(tuple, -1, inst=False, name='Tuple')
===========changed ref 0===========
# module: aioquic.buffer
class Buffer:
+ def pull_bytes(self, length: int) -> bytes:
+ """
+ Pull bytes.
+ """
+ end = self._pos + length
+ if end > self._length:
+ raise BufferReadError
+ v = bytes(self._data[self._pos : end])
+ self._pos = end
+ return v
+
===========changed ref 1===========
# module: aioquic.buffer
class Buffer:
+ def pull_uint16(self) -> int:
+ """
+ Pull a 16-bit unsigned integer.
+ """
+ try:
+ v, = struct.unpack_from("!H", self._data, self._pos)
+ self._pos += 2
+ return v
+ except struct.error:
+ raise BufferReadError
+
===========changed ref 2===========
# module: aioquic.buffer
class Buffer:
+ def pull_uint_var(self) -> int:
+ """
+ Pull a QUIC variable-length unsigned integer.
+ """
+ try:
+ kind = self._data[self._pos] // 64
+ if kind == 0:
+ value = self._data[self._pos]
+ self._pos += 1
+ return value
+ elif kind == 1:
+ value, = unpack_from("!H", self._data, self._pos)
+ self._pos += 2
+ return value & 0x3FFF
+ elif kind == 2:
+ value, = unpack_from("!L", self._data, self._pos)
+ self._pos += 4
+ return value & 0x3FFFFFFF
+ else:
+ value, = unpack_from("!Q", self._data, self._pos)
+ self._pos += 8
+ return value & 0x3FFFFFFFFFFFFFFF
+ except (IndexError, struct.error):
+ raise BufferReadError
+
===========changed ref 3===========
# module: aioquic.packet
def push_new_token_frame(buf: Buffer, token: bytes) -> None:
+ buf.push_uint_var(len(token))
- push_uint_var(buf, len(token))
+ buf.push_bytes(token)
- push_bytes(buf, token)
===========changed ref 4===========
# module: aioquic.packet
def pull_new_token_frame(buf: Buffer) -> bytes:
+ length = buf.pull_uint_var()
- length = pull_uint_var(buf)
+ return buf.pull_bytes(length)
- return pull_bytes(buf, length)
===========changed ref 5===========
# module: aioquic.packet
def pull_crypto_frame(buf: Buffer) -> QuicStreamFrame:
+ offset = buf.pull_uint_var()
- offset = pull_uint_var(buf)
+ length = buf.pull_uint_var()
- length = pull_uint_var(buf)
+ return QuicStreamFrame(offset=offset, data=buf.pull_bytes(length))
- return QuicStreamFrame(offset=offset, data=pull_bytes(buf, length))
===========changed ref 6===========
# module: aioquic.packet
def pull_new_connection_id_frame(buf: Buffer) -> Tuple[int, bytes, bytes]:
+ sequence_number = buf.pull_uint_var()
- sequence_number = pull_uint_var(buf)
+ length = buf.pull_uint8()
- length = pull_uint8(buf)
+ connection_id = buf.pull_bytes(length)
- connection_id = pull_bytes(buf, length)
+ stateless_reset_token = buf.pull_bytes(16)
- stateless_reset_token = pull_bytes(buf, 16)
return (sequence_number, connection_id, stateless_reset_token)
===========changed ref 7===========
# module: aioquic.packet
def push_quic_transport_parameters(
buf: Buffer, params: QuicTransportParameters
) -> None:
with push_block(buf, 2):
for param_id, (param_name, param_type) in enumerate(PARAMS):
param_value = getattr(params, param_name)
if param_value is not None and param_value is not False:
+ buf.push_uint16(param_id)
- push_uint16(buf, param_id)
with push_block(buf, 2):
if param_type == int:
+ buf.push_uint_var(param_value)
- push_uint_var(buf, param_value)
elif param_type == bytes:
+ buf.push_bytes(param_value)
- push_bytes(buf, param_value)
===========changed ref 8===========
# module: aioquic.packet
def push_ack_frame(buf: Buffer, rangeset: RangeSet, delay: int) -> None:
index = len(rangeset) - 1
r = rangeset[index]
+ buf.push_uint_var(r.stop - 1)
- push_uint_var(buf, r.stop - 1)
+ buf.push_uint_var(delay)
- push_uint_var(buf, delay)
+ buf.push_uint_var(index)
- push_uint_var(buf, index)
+ buf.push_uint_var(r.stop - 1 - r.start)
- push_uint_var(buf, r.stop - 1 - r.start)
start = r.start
while index > 0:
index -= 1
r = rangeset[index]
+ buf.push_uint_var(start - r.stop - 1)
- push_uint_var(buf, start - r.stop - 1)
+ buf.push_uint_var(r.stop - r.start - 1)
- push_uint_var(buf, r.stop - r.start - 1)
start = r.start
===========changed ref 9===========
# module: aioquic.packet
def pull_ack_frame(buf: Buffer) -> Tuple[RangeSet, int]:
rangeset = RangeSet()
+ end = buf.pull_uint_var() # largest acknowledged
- end = pull_uint_var(buf) # largest acknowledged
+ delay = buf.pull_uint_var()
- delay = pull_uint_var(buf)
+ ack_range_count = buf.pull_uint_var()
- ack_range_count = pull_uint_var(buf)
+ ack_count = buf.pull_uint_var() # first ack range
- ack_count = pull_uint_var(buf) # first ack range
rangeset.add(end - ack_count, end + 1)
end -= ack_count
for _ in range(ack_range_count):
+ end -= buf.pull_uint_var() + 2
- end -= pull_uint_var(buf) + 2
+ ack_count = buf.pull_uint_var()
- ack_count = pull_uint_var(buf)
rangeset.add(end - ack_count, end + 1)
end -= ack_count
return rangeset, delay
|
aioquic.packet/pull_transport_close_frame
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<0>:<add> error_code = buf.pull_uint16()
<del> error_code = pull_uint16(buf)
<1>:<add> frame_type = buf.pull_uint_var()
<del> frame_type = pull_uint_var(buf)
<2>:<add> reason_length = buf.pull_uint_var()
<del> reason_length = pull_uint_var(buf)
<3>:<add> reason_phrase = decode_reason_phrase(buf.pull_bytes(reason_length))
<del> reason_phrase = decode_reason_phrase(pull_bytes(buf, reason_length))
|
# module: aioquic.packet
def pull_transport_close_frame(buf: Buffer) -> Tuple[int, int, str]:
<0> error_code = pull_uint16(buf)
<1> frame_type = pull_uint_var(buf)
<2> reason_length = pull_uint_var(buf)
<3> reason_phrase = decode_reason_phrase(pull_bytes(buf, reason_length))
<4> return (error_code, frame_type, reason_phrase)
<5>
|
===========changed ref 0===========
# module: aioquic.packet
def push_new_token_frame(buf: Buffer, token: bytes) -> None:
+ buf.push_uint_var(len(token))
- push_uint_var(buf, len(token))
+ buf.push_bytes(token)
- push_bytes(buf, token)
===========changed ref 1===========
# module: aioquic.packet
def pull_new_token_frame(buf: Buffer) -> bytes:
+ length = buf.pull_uint_var()
- length = pull_uint_var(buf)
+ return buf.pull_bytes(length)
- return pull_bytes(buf, length)
===========changed ref 2===========
# module: aioquic.packet
def pull_crypto_frame(buf: Buffer) -> QuicStreamFrame:
+ offset = buf.pull_uint_var()
- offset = pull_uint_var(buf)
+ length = buf.pull_uint_var()
- length = pull_uint_var(buf)
+ return QuicStreamFrame(offset=offset, data=buf.pull_bytes(length))
- return QuicStreamFrame(offset=offset, data=pull_bytes(buf, length))
===========changed ref 3===========
# module: aioquic.packet
def push_new_connection_id_frame(
buf: Buffer,
sequence_number: int,
connection_id: bytes,
stateless_reset_token: bytes,
) -> None:
assert len(stateless_reset_token) == 16
+ buf.push_uint_var(sequence_number)
- push_uint_var(buf, sequence_number)
+ buf.push_uint8(len(connection_id))
- push_uint8(buf, len(connection_id))
+ buf.push_bytes(connection_id)
- push_bytes(buf, connection_id)
+ buf.push_bytes(stateless_reset_token)
- push_bytes(buf, stateless_reset_token)
===========changed ref 4===========
# module: aioquic.packet
def pull_new_connection_id_frame(buf: Buffer) -> Tuple[int, bytes, bytes]:
+ sequence_number = buf.pull_uint_var()
- sequence_number = pull_uint_var(buf)
+ length = buf.pull_uint8()
- length = pull_uint8(buf)
+ connection_id = buf.pull_bytes(length)
- connection_id = pull_bytes(buf, length)
+ stateless_reset_token = buf.pull_bytes(16)
- stateless_reset_token = pull_bytes(buf, 16)
return (sequence_number, connection_id, stateless_reset_token)
===========changed ref 5===========
# module: aioquic.packet
def push_quic_transport_parameters(
buf: Buffer, params: QuicTransportParameters
) -> None:
with push_block(buf, 2):
for param_id, (param_name, param_type) in enumerate(PARAMS):
param_value = getattr(params, param_name)
if param_value is not None and param_value is not False:
+ buf.push_uint16(param_id)
- push_uint16(buf, param_id)
with push_block(buf, 2):
if param_type == int:
+ buf.push_uint_var(param_value)
- push_uint_var(buf, param_value)
elif param_type == bytes:
+ buf.push_bytes(param_value)
- push_bytes(buf, param_value)
===========changed ref 6===========
# module: aioquic.packet
def push_ack_frame(buf: Buffer, rangeset: RangeSet, delay: int) -> None:
index = len(rangeset) - 1
r = rangeset[index]
+ buf.push_uint_var(r.stop - 1)
- push_uint_var(buf, r.stop - 1)
+ buf.push_uint_var(delay)
- push_uint_var(buf, delay)
+ buf.push_uint_var(index)
- push_uint_var(buf, index)
+ buf.push_uint_var(r.stop - 1 - r.start)
- push_uint_var(buf, r.stop - 1 - r.start)
start = r.start
while index > 0:
index -= 1
r = rangeset[index]
+ buf.push_uint_var(start - r.stop - 1)
- push_uint_var(buf, start - r.stop - 1)
+ buf.push_uint_var(r.stop - r.start - 1)
- push_uint_var(buf, r.stop - r.start - 1)
start = r.start
===========changed ref 7===========
# module: aioquic.packet
def pull_ack_frame(buf: Buffer) -> Tuple[RangeSet, int]:
rangeset = RangeSet()
+ end = buf.pull_uint_var() # largest acknowledged
- end = pull_uint_var(buf) # largest acknowledged
+ delay = buf.pull_uint_var()
- delay = pull_uint_var(buf)
+ ack_range_count = buf.pull_uint_var()
- ack_range_count = pull_uint_var(buf)
+ ack_count = buf.pull_uint_var() # first ack range
- ack_count = pull_uint_var(buf) # first ack range
rangeset.add(end - ack_count, end + 1)
end -= ack_count
for _ in range(ack_range_count):
+ end -= buf.pull_uint_var() + 2
- end -= pull_uint_var(buf) + 2
+ ack_count = buf.pull_uint_var()
- ack_count = pull_uint_var(buf)
rangeset.add(end - ack_count, end + 1)
end -= ack_count
return rangeset, delay
===========changed ref 8===========
# module: aioquic.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_id = pull_uint16(buf)
+ param_len = buf.pull_uint16()
- param_len = pull_uint16(buf)
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())
- setattr(params, param_name, pull_uint_var(buf))
elif param_type == bytes:
+ setattr(params, param_name, buf.pull_bytes(param_len))
- setattr(params, param_name, pull_bytes(buf, param_len))
else:
setattr(params, param_name, True)
else:
# skip unknown parameter
+ buf.pull_bytes(param_len)
- pull_bytes(buf, param_len)
assert buf.tell() == param_start + param_len
return params
|
aioquic.packet/pull_application_close_frame
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<0>:<add> error_code = buf.pull_uint16()
<del> error_code = pull_uint16(buf)
<1>:<add> reason_length = buf.pull_uint_var()
<del> reason_length = pull_uint_var(buf)
<2>:<add> reason_phrase = decode_reason_phrase(buf.pull_bytes(reason_length))
<del> reason_phrase = decode_reason_phrase(pull_bytes(buf, reason_length))
|
# module: aioquic.packet
def pull_application_close_frame(buf: Buffer) -> Tuple[int, str]:
<0> error_code = pull_uint16(buf)
<1> reason_length = pull_uint_var(buf)
<2> reason_phrase = decode_reason_phrase(pull_bytes(buf, reason_length))
<3> return (error_code, reason_phrase)
<4>
|
===========changed ref 0===========
# module: aioquic.packet
def push_new_token_frame(buf: Buffer, token: bytes) -> None:
+ buf.push_uint_var(len(token))
- push_uint_var(buf, len(token))
+ buf.push_bytes(token)
- push_bytes(buf, token)
===========changed ref 1===========
# module: aioquic.packet
def pull_new_token_frame(buf: Buffer) -> bytes:
+ length = buf.pull_uint_var()
- length = pull_uint_var(buf)
+ return buf.pull_bytes(length)
- return pull_bytes(buf, length)
===========changed ref 2===========
# module: aioquic.packet
def pull_crypto_frame(buf: Buffer) -> QuicStreamFrame:
+ offset = buf.pull_uint_var()
- offset = pull_uint_var(buf)
+ length = buf.pull_uint_var()
- length = pull_uint_var(buf)
+ return QuicStreamFrame(offset=offset, data=buf.pull_bytes(length))
- return QuicStreamFrame(offset=offset, data=pull_bytes(buf, length))
===========changed ref 3===========
# module: aioquic.packet
def push_new_connection_id_frame(
buf: Buffer,
sequence_number: int,
connection_id: bytes,
stateless_reset_token: bytes,
) -> None:
assert len(stateless_reset_token) == 16
+ buf.push_uint_var(sequence_number)
- push_uint_var(buf, sequence_number)
+ buf.push_uint8(len(connection_id))
- push_uint8(buf, len(connection_id))
+ buf.push_bytes(connection_id)
- push_bytes(buf, connection_id)
+ buf.push_bytes(stateless_reset_token)
- push_bytes(buf, stateless_reset_token)
===========changed ref 4===========
# module: aioquic.packet
def pull_transport_close_frame(buf: Buffer) -> Tuple[int, int, str]:
+ error_code = buf.pull_uint16()
- error_code = pull_uint16(buf)
+ frame_type = buf.pull_uint_var()
- frame_type = pull_uint_var(buf)
+ reason_length = buf.pull_uint_var()
- reason_length = pull_uint_var(buf)
+ reason_phrase = decode_reason_phrase(buf.pull_bytes(reason_length))
- reason_phrase = decode_reason_phrase(pull_bytes(buf, reason_length))
return (error_code, frame_type, reason_phrase)
===========changed ref 5===========
# module: aioquic.packet
def pull_new_connection_id_frame(buf: Buffer) -> Tuple[int, bytes, bytes]:
+ sequence_number = buf.pull_uint_var()
- sequence_number = pull_uint_var(buf)
+ length = buf.pull_uint8()
- length = pull_uint8(buf)
+ connection_id = buf.pull_bytes(length)
- connection_id = pull_bytes(buf, length)
+ stateless_reset_token = buf.pull_bytes(16)
- stateless_reset_token = pull_bytes(buf, 16)
return (sequence_number, connection_id, stateless_reset_token)
===========changed ref 6===========
# module: aioquic.packet
def push_quic_transport_parameters(
buf: Buffer, params: QuicTransportParameters
) -> None:
with push_block(buf, 2):
for param_id, (param_name, param_type) in enumerate(PARAMS):
param_value = getattr(params, param_name)
if param_value is not None and param_value is not False:
+ buf.push_uint16(param_id)
- push_uint16(buf, param_id)
with push_block(buf, 2):
if param_type == int:
+ buf.push_uint_var(param_value)
- push_uint_var(buf, param_value)
elif param_type == bytes:
+ buf.push_bytes(param_value)
- push_bytes(buf, param_value)
===========changed ref 7===========
# module: aioquic.packet
def push_ack_frame(buf: Buffer, rangeset: RangeSet, delay: int) -> None:
index = len(rangeset) - 1
r = rangeset[index]
+ buf.push_uint_var(r.stop - 1)
- push_uint_var(buf, r.stop - 1)
+ buf.push_uint_var(delay)
- push_uint_var(buf, delay)
+ buf.push_uint_var(index)
- push_uint_var(buf, index)
+ buf.push_uint_var(r.stop - 1 - r.start)
- push_uint_var(buf, r.stop - 1 - r.start)
start = r.start
while index > 0:
index -= 1
r = rangeset[index]
+ buf.push_uint_var(start - r.stop - 1)
- push_uint_var(buf, start - r.stop - 1)
+ buf.push_uint_var(r.stop - r.start - 1)
- push_uint_var(buf, r.stop - r.start - 1)
start = r.start
===========changed ref 8===========
# module: aioquic.packet
def pull_ack_frame(buf: Buffer) -> Tuple[RangeSet, int]:
rangeset = RangeSet()
+ end = buf.pull_uint_var() # largest acknowledged
- end = pull_uint_var(buf) # largest acknowledged
+ delay = buf.pull_uint_var()
- delay = pull_uint_var(buf)
+ ack_range_count = buf.pull_uint_var()
- ack_range_count = pull_uint_var(buf)
+ ack_count = buf.pull_uint_var() # first ack range
- ack_count = pull_uint_var(buf) # first ack range
rangeset.add(end - ack_count, end + 1)
end -= ack_count
for _ in range(ack_range_count):
+ end -= buf.pull_uint_var() + 2
- end -= pull_uint_var(buf) + 2
+ ack_count = buf.pull_uint_var()
- ack_count = pull_uint_var(buf)
rangeset.add(end - ack_count, end + 1)
end -= ack_count
return rangeset, delay
===========changed ref 9===========
# module: aioquic.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_id = pull_uint16(buf)
+ param_len = buf.pull_uint16()
- param_len = pull_uint16(buf)
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())
- setattr(params, param_name, pull_uint_var(buf))
elif param_type == bytes:
+ setattr(params, param_name, buf.pull_bytes(param_len))
- setattr(params, param_name, pull_bytes(buf, param_len))
else:
setattr(params, param_name, True)
else:
# skip unknown parameter
+ buf.pull_bytes(param_len)
- pull_bytes(buf, param_len)
assert buf.tell() == param_start + param_len
return params
|
aioquic.packet_builder/QuicPacketBuilder.start_frame
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<3>:<add> self.buffer.push_uint_var(frame_type)
<del> push_uint_var(self.buffer, frame_type)
|
# module: aioquic.packet_builder
class QuicPacketBuilder:
def start_frame(
self,
frame_type: int,
handler: Optional[QuicDeliveryHandler] = None,
args: Sequence[Any] = [],
) -> None:
<0> """
<1> Starts a new frame.
<2> """
<3> push_uint_var(self.buffer, frame_type)
<4> if frame_type not in NON_ACK_ELICITING_FRAME_TYPES:
<5> # FIXME: in_flight != is_ack_eliciting
<6> self._packet.in_flight = True
<7> self._packet.is_ack_eliciting = True
<8> self._ack_eliciting = True
<9> if frame_type == QuicFrameType.CRYPTO:
<10> self._packet.is_crypto_packet = True
<11> if handler is not None:
<12> self._packet.delivery_handlers.append((handler, args))
<13>
|
===========unchanged ref 0===========
at: aioquic.buffer.Buffer
tell() -> int
at: aioquic.crypto
CryptoPair()
at: aioquic.packet
PACKET_TYPE_INITIAL = PACKET_LONG_HEADER | PACKET_FIXED_BIT | 0x00
PACKET_TYPE_HANDSHAKE = PACKET_LONG_HEADER | PACKET_FIXED_BIT | 0x20
at: aioquic.packet_builder.QuicPacketBuilder
_flush_current_datagram() -> None
_flush_current_datagram(self) -> None
at: aioquic.packet_builder.QuicPacketBuilder.__init__
self._ack_eliciting = False
self._packet: Optional[QuicSentPacket] = None
self.buffer = Buffer(PACKET_MAX_SIZE)
at: aioquic.packet_builder.QuicPacketBuilder.end_packet
self._packet = None
at: aioquic.packet_builder.QuicPacketBuilder.start_frame
self._ack_eliciting = True
at: aioquic.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,
)
at: aioquic.packet_builder.QuicSentPacket
epoch: Epoch
in_flight: bool
is_ack_eliciting: bool
is_crypto_packet: bool
packet_number: int
sent_time: Optional[float] = None
sent_bytes: int = 0
delivery_handlers: List[Tuple[QuicDeliveryHandler, Any]] = field(
default_factory=list
)
at: aioquic.tls
Epoch()
===========changed ref 0===========
# module: aioquic.packet_builder
- def push_packet_number(buf: Buffer, packet_number: int) -> None:
- """
- Packet numbers are truncated and encoded using 1, 2 or 4 bytes.
-
- We choose to use 2 bytes which provides a good tradeoff between encoded
- size and the "window" of packets we can represent.
- """
- push_uint16(buf, packet_number & 0xFFFF)
-
===========changed ref 1===========
# module: aioquic.tls
def pull_group(buf: Buffer) -> Group:
+ return Group(buf.pull_uint16())
- return Group(pull_uint16(buf))
===========changed ref 2===========
# module: aioquic.tls
def pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm:
+ return SignatureAlgorithm(buf.pull_uint16())
- return SignatureAlgorithm(pull_uint16(buf))
===========changed ref 3===========
# module: aioquic.tls
def pull_compression_method(buf: Buffer) -> CompressionMethod:
+ return CompressionMethod(buf.pull_uint8())
- return CompressionMethod(pull_uint8(buf))
===========changed ref 4===========
# module: aioquic.tls
# INTEGERS
def pull_cipher_suite(buf: Buffer) -> CipherSuite:
+ return CipherSuite(buf.pull_uint16())
- return CipherSuite(pull_uint16(buf))
===========changed ref 5===========
# module: aioquic.tls
def pull_key_exchange_mode(buf: Buffer) -> KeyExchangeMode:
+ return KeyExchangeMode(buf.pull_uint8())
- return KeyExchangeMode(pull_uint8(buf))
===========changed ref 6===========
# module: aioquic.buffer
class Buffer:
+ def push_uint8(self, v: int) -> None:
+ """
+ Push an 8-bit unsigned integer.
+ """
+ self._data[self._pos] = v
+ self._pos += 1
+
===========changed ref 7===========
# module: aioquic.tls
def push_key_share(buf: Buffer, value: KeyShareEntry) -> None:
+ buf.push_uint16(value[0])
- push_group(buf, value[0])
push_opaque(buf, 2, value[1])
===========changed ref 8===========
# module: aioquic.tls
@contextmanager
def push_extension(buf: Buffer, extension_type: int) -> Generator:
+ buf.push_uint16(extension_type)
- push_uint16(buf, extension_type)
with push_block(buf, 2):
yield
===========changed ref 9===========
# module: aioquic.buffer
- def push_uint8(buf: Buffer, v: int) -> None:
- """
- Push an 8-bit unsigned integer.
- """
- buf._data[buf._pos] = v
- buf._pos += 1
-
===========changed ref 10===========
# module: aioquic.tls
def push_psk_identity(buf: Buffer, entry: PskIdentity) -> None:
push_opaque(buf, 2, entry[0])
+ buf.push_uint32(entry[1])
- push_uint32(buf, entry[1])
===========changed ref 11===========
# module: aioquic.buffer
class Buffer:
+ def push_uint64(self, v: int) -> None:
+ """
+ Push a 64-bit unsigned integer.
+ """
+ pack_into("!Q", self._data, self._pos, v)
+ self._pos += 8
+
===========changed ref 12===========
# module: aioquic.buffer
class Buffer:
+ def push_uint32(self, v: int) -> None:
+ """
+ Push a 32-bit unsigned integer.
+ """
+ pack_into("!L", self._data, self._pos, v)
+ self._pos += 4
+
===========changed ref 13===========
# module: aioquic.buffer
class Buffer:
+ def push_uint16(self, v: int) -> None:
+ """
+ Push a 16-bit unsigned integer.
+ """
+ pack_into("!H", self._data, self._pos, v)
+ self._pos += 2
+
===========changed ref 14===========
# module: aioquic.tls
def push_list(
+ buf: Buffer, capacity: int, func: Callable[[T], None], values: Sequence[T]
- buf: Buffer, capacity: int, func: Callable[[Buffer, T], None], values: Sequence[T]
) -> None:
"""
Push a list of items.
"""
with push_block(buf, capacity):
for value in values:
+ func(value)
- func(buf, value)
===========changed ref 15===========
# module: aioquic.packet
def pull_new_token_frame(buf: Buffer) -> bytes:
+ length = buf.pull_uint_var()
- length = pull_uint_var(buf)
+ return buf.pull_bytes(length)
- return pull_bytes(buf, length)
===========changed ref 16===========
# module: aioquic.tls
def push_finished(buf: Buffer, finished: Finished) -> None:
+ buf.push_uint8(HandshakeType.FINISHED)
- push_uint8(buf, HandshakeType.FINISHED)
push_opaque(buf, 3, finished.verify_data)
===========changed ref 17===========
# module: aioquic.buffer
- def push_uint64(buf: Buffer, v: int) -> None:
- """
- Push a 64-bit unsigned integer.
- """
- pack_into("!Q", buf._data, buf._pos, v)
- buf._pos += 8
-
===========changed ref 18===========
# module: aioquic.buffer
- def push_uint32(buf: Buffer, v: int) -> None:
- """
- Push a 32-bit unsigned integer.
- """
- pack_into("!L", buf._data, buf._pos, v)
- buf._pos += 4
-
===========changed ref 19===========
# module: aioquic.buffer
- def push_uint16(buf: Buffer, v: int) -> None:
- """
- Push a 16-bit unsigned integer.
- """
- pack_into("!H", buf._data, buf._pos, v)
- buf._pos += 2
-
|
aioquic.packet_builder/QuicPacketBuilder.end_packet
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<13>:<add> buf.push_bytes(bytes(self.remaining_space))
<del> push_bytes(buf, bytes(self.remaining_space))
<27>:<add> buf.push_uint8(self._packet_type | (PACKET_NUMBER_SEND_SIZE - 1))
<del> push_uint8(buf, self._packet_type | (PACKET_NUMBER_SEND_SIZE - 1))
<28>:<add> buf.push_uint32(self._version)
<del> push_uint32(buf, self._version)
<29>:<add> buf.push_uint8(
<del> push_uint8(
<30>:<del> buf,
<32>:<add> | encode_cid_length(len(self._host_cid))
<del> | encode_cid_length(len(self._host_cid)),
<34>:<add> buf.push_bytes(self._peer_cid)
<del> push_bytes(buf, self._peer_cid)
<35>:<add> buf.push_bytes(self._host_cid)
<del> push_bytes(buf, self._host_cid)
<37>:<add> buf.push_uint_var(len(self._peer_token))
<del> push_uint_var(buf, len(self._peer_token))
<38>:<add> buf.push_bytes(self._peer_token)
<del> push_bytes(buf, self._peer_token)
<39>:<add> buf.push_uint16(length | 0x4000)
<del> push_uint16(buf, length | 0x4000)
<40>:<add> buf.push_uint16(self._packet_number & 0xFFFF)
<del> push_packet_number(buf, self._packet_number)
|
# module: aioquic.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> push_bytes(buf, bytes(self.remaining_space))
<14> packet_size = buf.tell() - self._packet_start
<15> self._pad_first_datagram = False
<16>
<17> # write header
<18> if is_long_header(self._packet_type):
<19> length = (
<20> packet_size
<21> - self._header_size
<22> + PACKET_NUMBER_SEND_SIZE
<23> + self._packet_crypto.aead_tag_size
<24> )
<25>
<26> buf.seek(self._packet_start)
<27> push_uint8(buf, self._packet_type | (PACKET_NUMBER_SEND_SIZE - 1))
<28> push_uint32(buf, self._version)
<29> push_uint8(
<30> buf,
<31> (encode_cid_length(len(self._peer_cid)) << 4)
<32> | encode_cid_length(len(self._host_cid)),
<33> )
<34> push_bytes(buf, self._peer_cid)
<35> push_bytes(buf, self._host_cid)
<36> if (self._packet_type & PACKET_TYPE_MASK) == PACKET_TYPE_INITIAL:
<37> push_uint_var(buf, len(self._peer_token))
<38> push_bytes(buf, self._peer_token)
<39> push_uint16(buf, length | 0x4000)
<40> push_packet_number(buf, self._packet_number)
<41> else:
<42> </s>
|
===========below chunk 0===========
# module: aioquic.packet_builder
class QuicPacketBuilder:
def end_packet(self) -> bool:
# offset: 1
push_uint8(
buf,
self._packet_type
| (self._spin_bit << 5)
| (self._packet_crypto.key_phase << 2)
| (PACKET_NUMBER_SEND_SIZE - 1),
)
push_bytes(buf, self._peer_cid)
push_packet_number(buf, self._packet_number)
# 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)
push_bytes(buf, 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)
push_bytes(
buf,
self._packet_crypto.encrypt_packet(
plain[0 : self._header_size], plain[self._header_size : packet_size]
),
)
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 is_long_header(self._packet_type):
self._flush_current_datagram()
self._packet_number += 1
else:
# "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(v: bytes) -> None
push_uint8(v: int) -> None
push_uint16(v: int) -> None
push_uint32(v: int) -> None
push_uint_var(value: int) -> None
at: aioquic.crypto.CryptoPair
encrypt_packet(plain_header: bytes, plain_payload: bytes) -> bytes
at: aioquic.crypto.CryptoPair.__init__
self.aead_tag_size = 16
at: aioquic.packet
PACKET_TYPE_INITIAL = PACKET_LONG_HEADER | PACKET_FIXED_BIT | 0x00
PACKET_TYPE_MASK = 0xF0
PACKET_NUMBER_MAX_SIZE = 4
encode_cid_length(length: int) -> int
is_long_header(first_byte: int) -> bool
at: aioquic.packet_builder
PACKET_NUMBER_SEND_SIZE = 2
at: aioquic.packet_builder.QuicPacketBuilder.__init__
self._host_cid = host_cid
self._peer_cid = peer_cid
self._peer_token = peer_token
self._spin_bit = spin_bit
self._version = version
self._ack_eliciting = False
self._datagrams: List[bytes] = []
self._packets: List[QuicSentPacket] = []
self._total_bytes = 0
self._header_size = 0
self._packet: Optional[QuicSentPacket] = None
self._packet_crypto: Optional[CryptoPair] = None
self._packet_number = packet_number
self._packet_start = 0
self._packet_type = 0
self.buffer = Buffer(PACKET_MAX_SIZE)
===========unchanged ref 1===========
at: aioquic.packet_builder.QuicPacketBuilder.end_packet
buf = self.buffer
empty = True
empty = False
at: aioquic.packet_builder.QuicPacketBuilder.flush
self._datagrams = []
self._packets = []
at: aioquic.packet_builder.QuicPacketBuilder.start_frame
self._ack_eliciting = True
at: aioquic.packet_builder.QuicPacketBuilder.start_packet
self._ack_eliciting = False
self._packet = QuicSentPacket(
epoch=epoch,
in_flight=False,
is_ack_eliciting=False,
is_crypto_packet=False,
packet_number=self._packet_number,
)
self._packet_crypto = crypto
self._packet_start = buf.tell()
self._packet_type = packet_type
self._header_size = 10 + len(self._peer_cid) + len(self._host_cid)
self._header_size += size_uint_var(token_length) + token_length
self._header_size = 3 + len(self._peer_cid)
at: aioquic.packet_builder.QuicSentPacket
sent_bytes: int = 0
===========changed ref 0===========
# module: aioquic.buffer
class Buffer:
+ def push_uint8(self, v: int) -> None:
+ """
+ Push an 8-bit unsigned integer.
+ """
+ self._data[self._pos] = v
+ self._pos += 1
+
===========changed ref 1===========
# module: aioquic.buffer
class Buffer:
+ def push_uint32(self, v: int) -> None:
+ """
+ Push a 32-bit unsigned integer.
+ """
+ pack_into("!L", self._data, self._pos, v)
+ self._pos += 4
+
===========changed ref 2===========
# module: aioquic.buffer
class Buffer:
+ def push_uint16(self, v: int) -> None:
+ """
+ Push a 16-bit unsigned integer.
+ """
+ pack_into("!H", self._data, self._pos, v)
+ self._pos += 2
+
===========changed ref 3===========
# module: aioquic.buffer
class Buffer:
+ def push_bytes(self, v: bytes) -> None:
+ """
+ Push bytes.
+ """
+ end = self._pos + len(v)
+ if end > self._length:
+ raise BufferWriteError
+ self._data[self._pos : end] = v
+ self._pos = end
+
===========changed ref 4===========
# module: aioquic.buffer
class Buffer:
+ def push_uint_var(self, value: int) -> None:
+ """
+ Push a QUIC variable-length unsigned integer.
+ """
+ if value <= 0x3F:
+ self._data[self._pos] = value
+ self._pos += 1
+ elif value <= 0x3FFF:
+ pack_into("!H", self._data, self._pos, value | 0x4000)
+ self._pos += 2
+ elif value <= 0x3FFFFFFF:
+ pack_into("!L", self._data, self._pos, value | 0x80000000)
+ self._pos += 4
+ elif value <= 0x3FFFFFFFFFFFFFFF:
+ pack_into("!Q", self._data, self._pos, value | 0xC000000000000000)
+ self._pos += 8
+ else:
+ raise ValueError("Integer is too big for a variable-length integer")
+
|
aioquic.stream/QuicStream.get_frame
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<25>:<add> data=bytes(
<add> self._send_buffer[
<del> data=self._send_buffer[
<26>:<add> start - self._send_buffer_start : stop - self._send_buffer_start
<del> start - self._send_buffer_start : stop - self._send_buffer_start
<27>:<add> ]
<add> ),
<del> ],
|
# module: aioquic.stream
class QuicStream(asyncio.Transport):
def get_frame(
self, max_size: int, max_offset: Optional[int] = None
) -> Optional[QuicStreamFrame]:
<0> """
<1> Get a frame of data to send.
<2> """
<3> # get the first pending data range
<4> try:
<5> r = self._send_pending[0]
<6> except IndexError:
<7> if self._send_pending_eof:
<8> # FIN only
<9> self._send_pending_eof = False
<10> return QuicStreamFrame(fin=True, offset=self._send_buffer_fin)
<11>
<12> self.send_buffer_is_empty = True
<13> return None
<14>
<15> # apply flow control
<16> start = r.start
<17> stop = min(r.stop, start + max_size)
<18> if max_offset is not None and stop > max_offset:
<19> stop = max_offset
<20> if stop <= start:
<21> return None
<22>
<23> # create frame
<24> frame = QuicStreamFrame(
<25> data=self._send_buffer[
<26> start - self._send_buffer_start : stop - self._send_buffer_start
<27> ],
<28> offset=start,
<29> )
<30> self._send_pending.subtract(start, stop)
<31>
<32> # track the highest offset ever sent
<33> if stop > self._send_highest:
<34> self._send_highest = stop
<35>
<36> # if the buffer is empty and EOF was written, set the FIN bit
<37> if self._send_buffer_fin == stop:
<38> frame.fin = True
<39> self._send_pending_eof = False
<40>
<41> return frame
<42>
|
===========unchanged ref 0===========
at: aioquic.packet
QuicStreamFrame(data: bytes=b"", fin: bool=False, offset: int=0)
at: aioquic.packet.QuicStreamFrame
data: bytes = b""
fin: bool = False
offset: int = 0
at: aioquic.rangeset.RangeSet
subtract(start: int, stop: int) -> None
at: aioquic.stream.QuicStream.__init__
self.send_buffer_is_empty = True
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_highest = 0
self._send_pending = RangeSet()
self._send_pending_eof = False
at: aioquic.stream.QuicStream.on_data_delivery
self.send_buffer_is_empty = False
self._send_buffer_start += size
self._send_pending_eof = True
at: aioquic.stream.QuicStream.write
self.send_buffer_is_empty = False
self._send_buffer += data
at: aioquic.stream.QuicStream.write_eof
self.send_buffer_is_empty = False
self._send_buffer_fin = self._send_buffer_stop
self._send_pending_eof = True
===========changed ref 0===========
# module: aioquic.tls
def pull_group(buf: Buffer) -> Group:
+ return Group(buf.pull_uint16())
- return Group(pull_uint16(buf))
===========changed ref 1===========
# module: aioquic.tls
def pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm:
+ return SignatureAlgorithm(buf.pull_uint16())
- return SignatureAlgorithm(pull_uint16(buf))
===========changed ref 2===========
# module: aioquic.tls
def pull_compression_method(buf: Buffer) -> CompressionMethod:
+ return CompressionMethod(buf.pull_uint8())
- return CompressionMethod(pull_uint8(buf))
===========changed ref 3===========
# module: aioquic.tls
# INTEGERS
def pull_cipher_suite(buf: Buffer) -> CipherSuite:
+ return CipherSuite(buf.pull_uint16())
- return CipherSuite(pull_uint16(buf))
===========changed ref 4===========
# module: aioquic.tls
def pull_key_exchange_mode(buf: Buffer) -> KeyExchangeMode:
+ return KeyExchangeMode(buf.pull_uint8())
- return KeyExchangeMode(pull_uint8(buf))
===========changed ref 5===========
# module: aioquic.buffer
class Buffer:
+ def push_uint8(self, v: int) -> None:
+ """
+ Push an 8-bit unsigned integer.
+ """
+ self._data[self._pos] = v
+ self._pos += 1
+
===========changed ref 6===========
# module: aioquic.tls
def push_key_share(buf: Buffer, value: KeyShareEntry) -> None:
+ buf.push_uint16(value[0])
- push_group(buf, value[0])
push_opaque(buf, 2, value[1])
===========changed ref 7===========
# module: aioquic.tls
@contextmanager
def push_extension(buf: Buffer, extension_type: int) -> Generator:
+ buf.push_uint16(extension_type)
- push_uint16(buf, extension_type)
with push_block(buf, 2):
yield
===========changed ref 8===========
# module: aioquic.buffer
- def push_uint8(buf: Buffer, v: int) -> None:
- """
- Push an 8-bit unsigned integer.
- """
- buf._data[buf._pos] = v
- buf._pos += 1
-
===========changed ref 9===========
# module: aioquic.tls
def push_psk_identity(buf: Buffer, entry: PskIdentity) -> None:
push_opaque(buf, 2, entry[0])
+ buf.push_uint32(entry[1])
- push_uint32(buf, entry[1])
===========changed ref 10===========
# module: aioquic.buffer
class Buffer:
+ def push_uint64(self, v: int) -> None:
+ """
+ Push a 64-bit unsigned integer.
+ """
+ pack_into("!Q", self._data, self._pos, v)
+ self._pos += 8
+
===========changed ref 11===========
# module: aioquic.buffer
class Buffer:
+ def push_uint32(self, v: int) -> None:
+ """
+ Push a 32-bit unsigned integer.
+ """
+ pack_into("!L", self._data, self._pos, v)
+ self._pos += 4
+
===========changed ref 12===========
# module: aioquic.buffer
class Buffer:
+ def push_uint16(self, v: int) -> None:
+ """
+ Push a 16-bit unsigned integer.
+ """
+ pack_into("!H", self._data, self._pos, v)
+ self._pos += 2
+
===========changed ref 13===========
# module: aioquic.tls
def push_list(
+ buf: Buffer, capacity: int, func: Callable[[T], None], values: Sequence[T]
- buf: Buffer, capacity: int, func: Callable[[Buffer, T], None], values: Sequence[T]
) -> None:
"""
Push a list of items.
"""
with push_block(buf, capacity):
for value in values:
+ func(value)
- func(buf, value)
===========changed ref 14===========
# module: aioquic.packet
def pull_new_token_frame(buf: Buffer) -> bytes:
+ length = buf.pull_uint_var()
- length = pull_uint_var(buf)
+ return buf.pull_bytes(length)
- return pull_bytes(buf, length)
===========changed ref 15===========
# module: aioquic.tls
def push_finished(buf: Buffer, finished: Finished) -> None:
+ buf.push_uint8(HandshakeType.FINISHED)
- push_uint8(buf, HandshakeType.FINISHED)
push_opaque(buf, 3, finished.verify_data)
===========changed ref 16===========
# module: aioquic.buffer
- def push_uint64(buf: Buffer, v: int) -> None:
- """
- Push a 64-bit unsigned integer.
- """
- pack_into("!Q", buf._data, buf._pos, v)
- buf._pos += 8
-
===========changed ref 17===========
# module: aioquic.buffer
- def push_uint32(buf: Buffer, v: int) -> None:
- """
- Push a 32-bit unsigned integer.
- """
- pack_into("!L", buf._data, buf._pos, v)
- buf._pos += 4
-
===========changed ref 18===========
# module: aioquic.buffer
- def push_uint16(buf: Buffer, v: int) -> None:
- """
- Push a 16-bit unsigned integer.
- """
- pack_into("!H", buf._data, buf._pos, v)
- buf._pos += 2
-
===========changed ref 19===========
# module: aioquic.tls
def push_opaque(buf: Buffer, capacity: int, value: bytes) -> None:
"""
Push an opaque value prefix by a length.
"""
with push_block(buf, capacity):
+ buf.push_bytes(value)
- push_bytes(buf, value)
===========changed ref 20===========
# module: aioquic.packet
def push_new_token_frame(buf: Buffer, token: bytes) -> None:
+ buf.push_uint_var(len(token))
- push_uint_var(buf, len(token))
+ buf.push_bytes(token)
- push_bytes(buf, token)
===========changed ref 21===========
# module: aioquic.tls
def pull_opaque(buf: Buffer, capacity: int) -> bytes:
"""
Pull an opaque value prefixed by a length.
"""
with pull_block(buf, capacity) as length:
+ return buf.pull_bytes(length)
- return pull_bytes(buf, length)
|
aioquic.connection/write_close_frame
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<6>:<add> buf.push_uint16(error_code)
<del> push_uint16(buf, error_code)
<7>:<add> buf.push_uint_var(len(reason_bytes))
<del> push_uint_var(buf, len(reason_bytes))
<8>:<add> buf.push_bytes(reason_bytes)
<del> push_bytes(buf, reason_bytes)
<11>:<add> buf.push_uint16(error_code)
<del> push_uint16(buf, error_code)
<12>:<add> buf.push_uint_var(frame_type)
<del> push_uint_var(buf, frame_type)
<13>:<add> buf.push_uint_var(len(reason_bytes))
<del> push_uint_var(buf, len(reason_bytes))
<14>:<add> buf.push_bytes(reason_bytes)
<del> push_bytes(buf, reason_bytes)
|
# module: aioquic.connection
def write_close_frame(
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> push_uint16(buf, error_code)
<7> push_uint_var(buf, len(reason_bytes))
<8> push_bytes(buf, reason_bytes)
<9> else:
<10> builder.start_frame(QuicFrameType.TRANSPORT_CLOSE)
<11> push_uint16(buf, error_code)
<12> push_uint_var(buf, frame_type)
<13> push_uint_var(buf, len(reason_bytes))
<14> push_bytes(buf, reason_bytes)
<15>
|
===========unchanged ref 0===========
at: aioquic.buffer
size_uint_var(value: int) -> int
at: aioquic.buffer.Buffer
push_bytes(v: bytes) -> None
push_uint16(v: int) -> None
push_uint_var(value: int) -> None
at: aioquic.connection.write_close_frame
buf = builder.buffer
reason_bytes = reason_phrase.encode("utf8")
at: aioquic.packet
QuicFrameType(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
QuicFrameType(x: Union[str, bytes, bytearray], base: int)
at: aioquic.packet_builder
QuicPacketBuilder(*, host_cid: bytes, peer_cid: bytes, version: int, pad_first_datagram: bool=False, packet_number: int=0, peer_token: bytes=b"", spin_bit: bool=False)
at: aioquic.packet_builder.QuicPacketBuilder
start_frame(frame_type: int, handler: Optional[QuicDeliveryHandler]=None, args: Sequence[Any]=[]) -> None
at: aioquic.packet_builder.QuicPacketBuilder.__init__
self.buffer = Buffer(PACKET_MAX_SIZE)
at: aioquic.recovery
QuicPacketSpace()
at: aioquic.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.stream.QuicStream
get_frame(max_size: int, max_offset: Optional[int]=None) -> Optional[QuicStreamFrame]
===========changed ref 0===========
# module: aioquic.buffer
class Buffer:
+ def push_uint16(self, v: int) -> None:
+ """
+ Push a 16-bit unsigned integer.
+ """
+ pack_into("!H", self._data, self._pos, v)
+ self._pos += 2
+
===========changed ref 1===========
# module: aioquic.buffer
class Buffer:
+ def push_bytes(self, v: bytes) -> None:
+ """
+ Push bytes.
+ """
+ end = self._pos + len(v)
+ if end > self._length:
+ raise BufferWriteError
+ self._data[self._pos : end] = v
+ self._pos = end
+
===========changed ref 2===========
# module: aioquic.packet_builder
class QuicPacketBuilder:
def start_frame(
self,
frame_type: int,
handler: Optional[QuicDeliveryHandler] = None,
args: Sequence[Any] = [],
) -> None:
"""
Starts a new frame.
"""
+ self.buffer.push_uint_var(frame_type)
- push_uint_var(self.buffer, frame_type)
if frame_type not in NON_ACK_ELICITING_FRAME_TYPES:
# FIXME: in_flight != is_ack_eliciting
self._packet.in_flight = True
self._packet.is_ack_eliciting = True
self._ack_eliciting = True
if frame_type == QuicFrameType.CRYPTO:
self._packet.is_crypto_packet = True
if handler is not None:
self._packet.delivery_handlers.append((handler, args))
===========changed ref 3===========
# module: aioquic.buffer
class Buffer:
+ def push_uint_var(self, value: int) -> None:
+ """
+ Push a QUIC variable-length unsigned integer.
+ """
+ if value <= 0x3F:
+ self._data[self._pos] = value
+ self._pos += 1
+ elif value <= 0x3FFF:
+ pack_into("!H", self._data, self._pos, value | 0x4000)
+ self._pos += 2
+ elif value <= 0x3FFFFFFF:
+ pack_into("!L", self._data, self._pos, value | 0x80000000)
+ self._pos += 4
+ elif value <= 0x3FFFFFFFFFFFFFFF:
+ pack_into("!Q", self._data, self._pos, value | 0xC000000000000000)
+ self._pos += 8
+ else:
+ raise ValueError("Integer is too big for a variable-length integer")
+
===========changed ref 4===========
# module: aioquic.stream
class QuicStream(asyncio.Transport):
def get_frame(
self, max_size: int, max_offset: Optional[int] = None
) -> Optional[QuicStreamFrame]:
"""
Get a frame of data to send.
"""
# get the first pending data range
try:
r = self._send_pending[0]
except IndexError:
if self._send_pending_eof:
# FIN only
self._send_pending_eof = False
return QuicStreamFrame(fin=True, offset=self._send_buffer_fin)
self.send_buffer_is_empty = True
return None
# apply flow control
start = r.start
stop = min(r.stop, start + max_size)
if max_offset is not None and stop > max_offset:
stop = max_offset
if stop <= start:
return None
# create frame
frame = QuicStreamFrame(
+ data=bytes(
+ self._send_buffer[
- data=self._send_buffer[
+ start - self._send_buffer_start : stop - self._send_buffer_start
- start - self._send_buffer_start : stop - self._send_buffer_start
+ ]
+ ),
- ],
offset=start,
)
self._send_pending.subtract(start, stop)
# track the highest offset ever sent
if stop > self._send_highest:
self._send_highest = stop
# if the buffer is empty and EOF was written, set the FIN bit
if self._send_buffer_fin == stop:
frame.fin = True
self._send_pending_eof = False
return frame
===========changed ref 5===========
# module: aioquic.tls
def pull_group(buf: Buffer) -> Group:
+ return Group(buf.pull_uint16())
- return Group(pull_uint16(buf))
===========changed ref 6===========
# module: aioquic.tls
def pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm:
+ return SignatureAlgorithm(buf.pull_uint16())
- return SignatureAlgorithm(pull_uint16(buf))
===========changed ref 7===========
# module: aioquic.tls
def pull_compression_method(buf: Buffer) -> CompressionMethod:
+ return CompressionMethod(buf.pull_uint8())
- return CompressionMethod(pull_uint8(buf))
===========changed ref 8===========
# module: aioquic.tls
# INTEGERS
def pull_cipher_suite(buf: Buffer) -> CipherSuite:
+ return CipherSuite(buf.pull_uint16())
- return CipherSuite(pull_uint16(buf))
===========changed ref 9===========
# module: aioquic.tls
def pull_key_exchange_mode(buf: Buffer) -> KeyExchangeMode:
+ return KeyExchangeMode(buf.pull_uint8())
- return KeyExchangeMode(pull_uint8(buf))
===========changed ref 10===========
# module: aioquic.buffer
class Buffer:
+ def push_uint8(self, v: int) -> None:
+ """
+ Push an 8-bit unsigned integer.
+ """
+ self._data[self._pos] = v
+ self._pos += 1
+
===========changed ref 11===========
# module: aioquic.tls
def push_key_share(buf: Buffer, value: KeyShareEntry) -> None:
+ buf.push_uint16(value[0])
- push_group(buf, value[0])
push_opaque(buf, 2, value[1])
|
aioquic.connection/write_crypto_frame
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<0>:<add> buf = builder.buffer
<add>
<8>:<add> buf.push_uint_var(frame.offset)
<del> push_uint_var(builder.buffer, frame.offset)
<9>:<add> buf.push_uint16(len(frame.data) | 0x4000)
<del> push_uint16(builder.buffer, len(frame.data) | 0x4000)
<10>:<add> buf.push_bytes(frame.data)
<del> push_bytes(builder.buffer, frame.data)
|
# module: aioquic.connection
def write_crypto_frame(
builder: QuicPacketBuilder, space: QuicPacketSpace, stream: QuicStream
) -> None:
<0> frame_overhead = 3 + size_uint_var(stream.next_send_offset)
<1> frame = stream.get_frame(builder.remaining_space - frame_overhead)
<2> if frame is not None:
<3> builder.start_frame(
<4> QuicFrameType.CRYPTO,
<5> stream.on_data_delivery,
<6> (frame.offset, frame.offset + len(frame.data)),
<7> )
<8> push_uint_var(builder.buffer, frame.offset)
<9> push_uint16(builder.buffer, len(frame.data) | 0x4000)
<10> push_bytes(builder.buffer, frame.data)
<11>
|
===========unchanged ref 0===========
at: aioquic.buffer.Buffer
push_bytes(v: bytes) -> None
push_uint16(v: int) -> None
push_uint_var(value: int) -> None
at: aioquic.connection.write_crypto_frame
buf = builder.buffer
frame = stream.get_frame(builder.remaining_space - frame_overhead)
at: aioquic.packet.QuicStreamFrame
data: bytes = b""
fin: bool = False
offset: int = 0
at: aioquic.packet_builder
QuicPacketBuilder(*, host_cid: bytes, peer_cid: bytes, version: int, pad_first_datagram: bool=False, packet_number: int=0, peer_token: bytes=b"", spin_bit: bool=False)
at: aioquic.packet_builder.QuicPacketBuilder.__init__
self.buffer = Buffer(PACKET_MAX_SIZE)
at: aioquic.recovery
QuicPacketSpace()
at: aioquic.stream
QuicStream(stream_id: Optional[int]=None, connection: Optional[Any]=None, max_stream_data_local: int=0, max_stream_data_remote: int=0)
===========changed ref 0===========
# module: aioquic.buffer
class Buffer:
+ def push_uint16(self, v: int) -> None:
+ """
+ Push a 16-bit unsigned integer.
+ """
+ pack_into("!H", self._data, self._pos, v)
+ self._pos += 2
+
===========changed ref 1===========
# module: aioquic.buffer
class Buffer:
+ def push_bytes(self, v: bytes) -> None:
+ """
+ Push bytes.
+ """
+ end = self._pos + len(v)
+ if end > self._length:
+ raise BufferWriteError
+ self._data[self._pos : end] = v
+ self._pos = end
+
===========changed ref 2===========
# module: aioquic.buffer
class Buffer:
+ def push_uint_var(self, value: int) -> None:
+ """
+ Push a QUIC variable-length unsigned integer.
+ """
+ if value <= 0x3F:
+ self._data[self._pos] = value
+ self._pos += 1
+ elif value <= 0x3FFF:
+ pack_into("!H", self._data, self._pos, value | 0x4000)
+ self._pos += 2
+ elif value <= 0x3FFFFFFF:
+ pack_into("!L", self._data, self._pos, value | 0x80000000)
+ self._pos += 4
+ elif value <= 0x3FFFFFFFFFFFFFFF:
+ pack_into("!Q", self._data, self._pos, value | 0xC000000000000000)
+ self._pos += 8
+ else:
+ raise ValueError("Integer is too big for a variable-length integer")
+
===========changed ref 3===========
# module: aioquic.connection
def write_close_frame(
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_uint16(error_code)
- push_uint16(buf, error_code)
+ buf.push_uint_var(len(reason_bytes))
- push_uint_var(buf, len(reason_bytes))
+ buf.push_bytes(reason_bytes)
- push_bytes(buf, reason_bytes)
else:
builder.start_frame(QuicFrameType.TRANSPORT_CLOSE)
+ buf.push_uint16(error_code)
- push_uint16(buf, error_code)
+ buf.push_uint_var(frame_type)
- push_uint_var(buf, frame_type)
+ buf.push_uint_var(len(reason_bytes))
- push_uint_var(buf, len(reason_bytes))
+ buf.push_bytes(reason_bytes)
- push_bytes(buf, reason_bytes)
===========changed ref 4===========
# module: aioquic.tls
def pull_group(buf: Buffer) -> Group:
+ return Group(buf.pull_uint16())
- return Group(pull_uint16(buf))
===========changed ref 5===========
# module: aioquic.tls
def pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm:
+ return SignatureAlgorithm(buf.pull_uint16())
- return SignatureAlgorithm(pull_uint16(buf))
===========changed ref 6===========
# module: aioquic.tls
def pull_compression_method(buf: Buffer) -> CompressionMethod:
+ return CompressionMethod(buf.pull_uint8())
- return CompressionMethod(pull_uint8(buf))
===========changed ref 7===========
# module: aioquic.tls
# INTEGERS
def pull_cipher_suite(buf: Buffer) -> CipherSuite:
+ return CipherSuite(buf.pull_uint16())
- return CipherSuite(pull_uint16(buf))
===========changed ref 8===========
# module: aioquic.tls
def pull_key_exchange_mode(buf: Buffer) -> KeyExchangeMode:
+ return KeyExchangeMode(buf.pull_uint8())
- return KeyExchangeMode(pull_uint8(buf))
===========changed ref 9===========
# module: aioquic.buffer
class Buffer:
+ def push_uint8(self, v: int) -> None:
+ """
+ Push an 8-bit unsigned integer.
+ """
+ self._data[self._pos] = v
+ self._pos += 1
+
===========changed ref 10===========
# module: aioquic.tls
def push_key_share(buf: Buffer, value: KeyShareEntry) -> None:
+ buf.push_uint16(value[0])
- push_group(buf, value[0])
push_opaque(buf, 2, value[1])
===========changed ref 11===========
# module: aioquic.tls
@contextmanager
def push_extension(buf: Buffer, extension_type: int) -> Generator:
+ buf.push_uint16(extension_type)
- push_uint16(buf, extension_type)
with push_block(buf, 2):
yield
===========changed ref 12===========
# module: aioquic.buffer
- def push_uint8(buf: Buffer, v: int) -> None:
- """
- Push an 8-bit unsigned integer.
- """
- buf._data[buf._pos] = v
- buf._pos += 1
-
===========changed ref 13===========
# module: aioquic.tls
def push_psk_identity(buf: Buffer, entry: PskIdentity) -> None:
push_opaque(buf, 2, entry[0])
+ buf.push_uint32(entry[1])
- push_uint32(buf, entry[1])
===========changed ref 14===========
# module: aioquic.buffer
class Buffer:
+ def push_uint64(self, v: int) -> None:
+ """
+ Push a 64-bit unsigned integer.
+ """
+ pack_into("!Q", self._data, self._pos, v)
+ self._pos += 8
+
===========changed ref 15===========
# module: aioquic.buffer
class Buffer:
+ def push_uint32(self, v: int) -> None:
+ """
+ Push a 32-bit unsigned integer.
+ """
+ pack_into("!L", self._data, self._pos, v)
+ self._pos += 4
+
===========changed ref 16===========
# module: aioquic.tls
def push_list(
+ buf: Buffer, capacity: int, func: Callable[[T], None], values: Sequence[T]
- buf: Buffer, capacity: int, func: Callable[[Buffer, T], None], values: Sequence[T]
) -> None:
"""
Push a list of items.
"""
with push_block(buf, capacity):
for value in values:
+ func(value)
- func(buf, value)
|
aioquic.connection/write_stream_frame
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<23>:<add> buf.push_uint_var(stream.stream_id)
<del> push_uint_var(buf, stream.stream_id)
<25>:<add> buf.push_uint_var(frame.offset)
<del> push_uint_var(buf, frame.offset)
<26>:<add> buf.push_uint16(len(frame.data) | 0x4000)
<del> push_uint16(buf, len(frame.data) | 0x4000)
<27>:<add> buf.push_bytes(frame.data)
<del> push_bytes(buf, frame.data)
|
# module: aioquic.connection
def write_stream_frame(
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> push_uint_var(buf, stream.stream_id)
<24> if frame.offset:
<25> push_uint_var(buf, frame.offset)
<26> push_uint16(buf, len(frame.data) | 0x4000)
<27> push_bytes(buf, frame.data)
<28> return stream._send_highest - previous_send_highest
<29> else:
<30> return 0
<31>
|
===========unchanged ref 0===========
at: aioquic.buffer
size_uint_var(value: int) -> int
at: aioquic.buffer.Buffer
push_bytes(v: bytes) -> None
push_uint16(v: int) -> None
push_uint_var(value: int) -> None
at: aioquic.connection.write_stream_frame
buf = builder.buffer
at: aioquic.packet
QuicFrameType(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
QuicFrameType(x: Union[str, bytes, bytearray], base: int)
at: aioquic.packet.QuicStreamFrame
data: bytes = b""
fin: bool = False
offset: int = 0
at: aioquic.packet_builder.QuicPacketBuilder
start_frame(frame_type: int, handler: Optional[QuicDeliveryHandler]=None, args: Sequence[Any]=[]) -> None
at: aioquic.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.stream.QuicStream.__init__
self._send_highest = 0
at: aioquic.stream.QuicStream.get_frame
self._send_highest = stop
===========changed ref 0===========
# module: aioquic.buffer
class Buffer:
+ def push_uint16(self, v: int) -> None:
+ """
+ Push a 16-bit unsigned integer.
+ """
+ pack_into("!H", self._data, self._pos, v)
+ self._pos += 2
+
===========changed ref 1===========
# module: aioquic.buffer
class Buffer:
+ def push_bytes(self, v: bytes) -> None:
+ """
+ Push bytes.
+ """
+ end = self._pos + len(v)
+ if end > self._length:
+ raise BufferWriteError
+ self._data[self._pos : end] = v
+ self._pos = end
+
===========changed ref 2===========
# module: aioquic.packet_builder
class QuicPacketBuilder:
def start_frame(
self,
frame_type: int,
handler: Optional[QuicDeliveryHandler] = None,
args: Sequence[Any] = [],
) -> None:
"""
Starts a new frame.
"""
+ self.buffer.push_uint_var(frame_type)
- push_uint_var(self.buffer, frame_type)
if frame_type not in NON_ACK_ELICITING_FRAME_TYPES:
# FIXME: in_flight != is_ack_eliciting
self._packet.in_flight = True
self._packet.is_ack_eliciting = True
self._ack_eliciting = True
if frame_type == QuicFrameType.CRYPTO:
self._packet.is_crypto_packet = True
if handler is not None:
self._packet.delivery_handlers.append((handler, args))
===========changed ref 3===========
# module: aioquic.buffer
class Buffer:
+ def push_uint_var(self, value: int) -> None:
+ """
+ Push a QUIC variable-length unsigned integer.
+ """
+ if value <= 0x3F:
+ self._data[self._pos] = value
+ self._pos += 1
+ elif value <= 0x3FFF:
+ pack_into("!H", self._data, self._pos, value | 0x4000)
+ self._pos += 2
+ elif value <= 0x3FFFFFFF:
+ pack_into("!L", self._data, self._pos, value | 0x80000000)
+ self._pos += 4
+ elif value <= 0x3FFFFFFFFFFFFFFF:
+ pack_into("!Q", self._data, self._pos, value | 0xC000000000000000)
+ self._pos += 8
+ else:
+ raise ValueError("Integer is too big for a variable-length integer")
+
===========changed ref 4===========
# module: aioquic.stream
class QuicStream(asyncio.Transport):
def get_frame(
self, max_size: int, max_offset: Optional[int] = None
) -> Optional[QuicStreamFrame]:
"""
Get a frame of data to send.
"""
# get the first pending data range
try:
r = self._send_pending[0]
except IndexError:
if self._send_pending_eof:
# FIN only
self._send_pending_eof = False
return QuicStreamFrame(fin=True, offset=self._send_buffer_fin)
self.send_buffer_is_empty = True
return None
# apply flow control
start = r.start
stop = min(r.stop, start + max_size)
if max_offset is not None and stop > max_offset:
stop = max_offset
if stop <= start:
return None
# create frame
frame = QuicStreamFrame(
+ data=bytes(
+ self._send_buffer[
- data=self._send_buffer[
+ start - self._send_buffer_start : stop - self._send_buffer_start
- start - self._send_buffer_start : stop - self._send_buffer_start
+ ]
+ ),
- ],
offset=start,
)
self._send_pending.subtract(start, stop)
# track the highest offset ever sent
if stop > self._send_highest:
self._send_highest = stop
# if the buffer is empty and EOF was written, set the FIN bit
if self._send_buffer_fin == stop:
frame.fin = True
self._send_pending_eof = False
return frame
===========changed ref 5===========
# module: aioquic.connection
def write_crypto_frame(
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)
- push_uint_var(builder.buffer, frame.offset)
+ buf.push_uint16(len(frame.data) | 0x4000)
- push_uint16(builder.buffer, len(frame.data) | 0x4000)
+ buf.push_bytes(frame.data)
- push_bytes(builder.buffer, frame.data)
|
aioquic.connection/QuicConnection._handle_ack_frame
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<5>:<add> buf.pull_uint_var()
<del> pull_uint_var(buf)
<6>:<add> buf.pull_uint_var()
<del> pull_uint_var(buf)
<7>:<add> buf.pull_uint_var()
<del> pull_uint_var(buf)
|
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_ack_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
<0> """
<1> Handle an ACK frame.
<2> """
<3> ack_rangeset, ack_delay_encoded = pull_ack_frame(buf)
<4> if frame_type == QuicFrameType.ACK_ECN:
<5> pull_uint_var(buf)
<6> pull_uint_var(buf)
<7> pull_uint_var(buf)
<8>
<9> self._loss.on_ack_received(
<10> space=self._spaces[context.epoch],
<11> ack_rangeset=ack_rangeset,
<12> ack_delay_encoded=ack_delay_encoded,
<13> now=context.time,
<14> )
<15>
<16> # check if we can discard handshake keys
<17> if (
<18> not self._handshake_confirmed
<19> and self._handshake_complete
<20> and context.epoch == tls.Epoch.ONE_RTT
<21> ):
<22> self._discard_epoch(tls.Epoch.HANDSHAKE)
<23> self._handshake_confirmed = True
<24>
|
===========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.connection
QuicReceiveContext(epoch: tls.Epoch, host_cid: bytes, network_path: QuicNetworkPath, time: float)
at: aioquic.connection.QuicConnection
supported_versions = [QuicProtocolVersion.DRAFT_19, QuicProtocolVersion.DRAFT_20]
_discard_epoch(epoch: tls.Epoch) -> None
at: aioquic.connection.QuicConnection.__init__
self._handshake_complete = False
self._handshake_confirmed = False
self._loss = QuicPacketRecovery(send_probe=self._send_probe)
self._spaces: Dict[tls.Epoch, QuicPacketSpace] = {}
at: aioquic.connection.QuicConnection._handle_ack_frame
ack_rangeset, ack_delay_encoded = pull_ack_frame(buf)
ack_rangeset, ack_delay_encoded = pull_ack_frame(buf)
at: aioquic.connection.QuicConnection._handle_crypto_frame
self._handshake_complete = True
at: aioquic.connection.QuicConnection._initialize
self._spaces = {
tls.Epoch.INITIAL: QuicPacketSpace(),
tls.Epoch.HANDSHAKE: QuicPacketSpace(),
tls.Epoch.ONE_RTT: QuicPacketSpace(),
}
at: aioquic.connection.QuicReceiveContext
epoch: tls.Epoch
host_cid: bytes
network_path: QuicNetworkPath
time: float
at: aioquic.packet
QuicFrameType(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
QuicFrameType(x: Union[str, bytes, bytearray], base: int)
===========unchanged ref 1===========
pull_transport_close_frame(buf: Buffer) -> Tuple[int, int, str]
at: aioquic.recovery.QuicPacketRecovery
on_ack_received(space: QuicPacketSpace, ack_rangeset: RangeSet, ack_delay_encoded: int, now: float) -> None
at: aioquic.tls
Epoch()
===========changed ref 0===========
# module: aioquic.packet
def pull_transport_close_frame(buf: Buffer) -> Tuple[int, int, str]:
+ error_code = buf.pull_uint16()
- error_code = pull_uint16(buf)
+ frame_type = buf.pull_uint_var()
- frame_type = pull_uint_var(buf)
+ reason_length = buf.pull_uint_var()
- reason_length = pull_uint_var(buf)
+ reason_phrase = decode_reason_phrase(buf.pull_bytes(reason_length))
- reason_phrase = decode_reason_phrase(pull_bytes(buf, reason_length))
return (error_code, frame_type, reason_phrase)
===========changed ref 1===========
# module: aioquic.buffer
class Buffer:
+ def pull_uint_var(self) -> int:
+ """
+ Pull a QUIC variable-length unsigned integer.
+ """
+ try:
+ kind = self._data[self._pos] // 64
+ if kind == 0:
+ value = self._data[self._pos]
+ self._pos += 1
+ return value
+ elif kind == 1:
+ value, = unpack_from("!H", self._data, self._pos)
+ self._pos += 2
+ return value & 0x3FFF
+ elif kind == 2:
+ value, = unpack_from("!L", self._data, self._pos)
+ self._pos += 4
+ return value & 0x3FFFFFFF
+ else:
+ value, = unpack_from("!Q", self._data, self._pos)
+ self._pos += 8
+ return value & 0x3FFFFFFFFFFFFFFF
+ except (IndexError, struct.error):
+ raise BufferReadError
+
===========changed ref 2===========
# module: aioquic.connection
def write_crypto_frame(
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)
- push_uint_var(builder.buffer, frame.offset)
+ buf.push_uint16(len(frame.data) | 0x4000)
- push_uint16(builder.buffer, len(frame.data) | 0x4000)
+ buf.push_bytes(frame.data)
- push_bytes(builder.buffer, frame.data)
===========changed ref 3===========
# module: aioquic.tls
def pull_group(buf: Buffer) -> Group:
+ return Group(buf.pull_uint16())
- return Group(pull_uint16(buf))
===========changed ref 4===========
# module: aioquic.tls
def pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm:
+ return SignatureAlgorithm(buf.pull_uint16())
- return SignatureAlgorithm(pull_uint16(buf))
===========changed ref 5===========
# module: aioquic.tls
def pull_compression_method(buf: Buffer) -> CompressionMethod:
+ return CompressionMethod(buf.pull_uint8())
- return CompressionMethod(pull_uint8(buf))
===========changed ref 6===========
# module: aioquic.tls
# INTEGERS
def pull_cipher_suite(buf: Buffer) -> CipherSuite:
+ return CipherSuite(buf.pull_uint16())
- return CipherSuite(pull_uint16(buf))
===========changed ref 7===========
# module: aioquic.tls
def pull_key_exchange_mode(buf: Buffer) -> KeyExchangeMode:
+ return KeyExchangeMode(buf.pull_uint8())
- return KeyExchangeMode(pull_uint8(buf))
===========changed ref 8===========
# module: aioquic.buffer
class Buffer:
+ def push_uint8(self, v: int) -> None:
+ """
+ Push an 8-bit unsigned integer.
+ """
+ self._data[self._pos] = v
+ self._pos += 1
+
===========changed ref 9===========
# module: aioquic.tls
def push_key_share(buf: Buffer, value: KeyShareEntry) -> None:
+ buf.push_uint16(value[0])
- push_group(buf, value[0])
push_opaque(buf, 2, value[1])
===========changed ref 10===========
# module: aioquic.tls
@contextmanager
def push_extension(buf: Buffer, extension_type: int) -> Generator:
+ buf.push_uint16(extension_type)
- push_uint16(buf, extension_type)
with push_block(buf, 2):
yield
===========changed ref 11===========
# module: aioquic.buffer
- def push_uint8(buf: Buffer, v: int) -> None:
- """
- Push an 8-bit unsigned integer.
- """
- buf._data[buf._pos] = v
- buf._pos += 1
-
===========changed ref 12===========
# module: aioquic.tls
def push_psk_identity(buf: Buffer, entry: PskIdentity) -> None:
push_opaque(buf, 2, entry[0])
+ buf.push_uint32(entry[1])
- push_uint32(buf, entry[1])
===========changed ref 13===========
# module: aioquic.buffer
class Buffer:
+ def push_uint64(self, v: int) -> None:
+ """
+ Push a 64-bit unsigned integer.
+ """
+ pack_into("!Q", self._data, self._pos, v)
+ self._pos += 8
+
|
aioquic.connection/QuicConnection._handle_data_blocked_frame
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<3>:<add> buf.pull_uint_var() # limit
<del> pull_uint_var(buf) # limit
|
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_data_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
<0> """
<1> Handle a DATA_BLOCKED frame.
<2> """
<3> pull_uint_var(buf) # limit
<4>
|
===========unchanged ref 0===========
at: aioquic.buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic.connection
QuicReceiveContext(epoch: tls.Epoch, host_cid: bytes, network_path: QuicNetworkPath, time: float)
===========changed ref 0===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_ack_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle an ACK frame.
"""
ack_rangeset, ack_delay_encoded = pull_ack_frame(buf)
if frame_type == QuicFrameType.ACK_ECN:
+ buf.pull_uint_var()
- pull_uint_var(buf)
+ buf.pull_uint_var()
- pull_uint_var(buf)
+ buf.pull_uint_var()
- pull_uint_var(buf)
self._loss.on_ack_received(
space=self._spaces[context.epoch],
ack_rangeset=ack_rangeset,
ack_delay_encoded=ack_delay_encoded,
now=context.time,
)
# check if we can discard handshake keys
if (
not self._handshake_confirmed
and self._handshake_complete
and context.epoch == tls.Epoch.ONE_RTT
):
self._discard_epoch(tls.Epoch.HANDSHAKE)
self._handshake_confirmed = True
===========changed ref 1===========
# module: aioquic.tls
def pull_group(buf: Buffer) -> Group:
+ return Group(buf.pull_uint16())
- return Group(pull_uint16(buf))
===========changed ref 2===========
# module: aioquic.tls
def pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm:
+ return SignatureAlgorithm(buf.pull_uint16())
- return SignatureAlgorithm(pull_uint16(buf))
===========changed ref 3===========
# module: aioquic.tls
def pull_compression_method(buf: Buffer) -> CompressionMethod:
+ return CompressionMethod(buf.pull_uint8())
- return CompressionMethod(pull_uint8(buf))
===========changed ref 4===========
# module: aioquic.tls
# INTEGERS
def pull_cipher_suite(buf: Buffer) -> CipherSuite:
+ return CipherSuite(buf.pull_uint16())
- return CipherSuite(pull_uint16(buf))
===========changed ref 5===========
# module: aioquic.tls
def pull_key_exchange_mode(buf: Buffer) -> KeyExchangeMode:
+ return KeyExchangeMode(buf.pull_uint8())
- return KeyExchangeMode(pull_uint8(buf))
===========changed ref 6===========
# module: aioquic.buffer
class Buffer:
+ def push_uint8(self, v: int) -> None:
+ """
+ Push an 8-bit unsigned integer.
+ """
+ self._data[self._pos] = v
+ self._pos += 1
+
===========changed ref 7===========
# module: aioquic.tls
def push_key_share(buf: Buffer, value: KeyShareEntry) -> None:
+ buf.push_uint16(value[0])
- push_group(buf, value[0])
push_opaque(buf, 2, value[1])
===========changed ref 8===========
# module: aioquic.tls
@contextmanager
def push_extension(buf: Buffer, extension_type: int) -> Generator:
+ buf.push_uint16(extension_type)
- push_uint16(buf, extension_type)
with push_block(buf, 2):
yield
===========changed ref 9===========
# module: aioquic.buffer
- def push_uint8(buf: Buffer, v: int) -> None:
- """
- Push an 8-bit unsigned integer.
- """
- buf._data[buf._pos] = v
- buf._pos += 1
-
===========changed ref 10===========
# module: aioquic.tls
def push_psk_identity(buf: Buffer, entry: PskIdentity) -> None:
push_opaque(buf, 2, entry[0])
+ buf.push_uint32(entry[1])
- push_uint32(buf, entry[1])
===========changed ref 11===========
# module: aioquic.buffer
class Buffer:
+ def push_uint64(self, v: int) -> None:
+ """
+ Push a 64-bit unsigned integer.
+ """
+ pack_into("!Q", self._data, self._pos, v)
+ self._pos += 8
+
===========changed ref 12===========
# module: aioquic.buffer
class Buffer:
+ def push_uint32(self, v: int) -> None:
+ """
+ Push a 32-bit unsigned integer.
+ """
+ pack_into("!L", self._data, self._pos, v)
+ self._pos += 4
+
===========changed ref 13===========
# module: aioquic.buffer
class Buffer:
+ def push_uint16(self, v: int) -> None:
+ """
+ Push a 16-bit unsigned integer.
+ """
+ pack_into("!H", self._data, self._pos, v)
+ self._pos += 2
+
===========changed ref 14===========
# module: aioquic.tls
def push_list(
+ buf: Buffer, capacity: int, func: Callable[[T], None], values: Sequence[T]
- buf: Buffer, capacity: int, func: Callable[[Buffer, T], None], values: Sequence[T]
) -> None:
"""
Push a list of items.
"""
with push_block(buf, capacity):
for value in values:
+ func(value)
- func(buf, value)
===========changed ref 15===========
# module: aioquic.packet
def pull_new_token_frame(buf: Buffer) -> bytes:
+ length = buf.pull_uint_var()
- length = pull_uint_var(buf)
+ return buf.pull_bytes(length)
- return pull_bytes(buf, length)
===========changed ref 16===========
# module: aioquic.tls
def push_finished(buf: Buffer, finished: Finished) -> None:
+ buf.push_uint8(HandshakeType.FINISHED)
- push_uint8(buf, HandshakeType.FINISHED)
push_opaque(buf, 3, finished.verify_data)
===========changed ref 17===========
# module: aioquic.buffer
- def push_uint64(buf: Buffer, v: int) -> None:
- """
- Push a 64-bit unsigned integer.
- """
- pack_into("!Q", buf._data, buf._pos, v)
- buf._pos += 8
-
===========changed ref 18===========
# module: aioquic.buffer
- def push_uint32(buf: Buffer, v: int) -> None:
- """
- Push a 32-bit unsigned integer.
- """
- pack_into("!L", buf._data, buf._pos, v)
- buf._pos += 4
-
===========changed ref 19===========
# module: aioquic.buffer
- def push_uint16(buf: Buffer, v: int) -> None:
- """
- Push a 16-bit unsigned integer.
- """
- pack_into("!H", buf._data, buf._pos, v)
- buf._pos += 2
-
===========changed ref 20===========
# module: aioquic.tls
def push_opaque(buf: Buffer, capacity: int, value: bytes) -> None:
"""
Push an opaque value prefix by a length.
"""
with push_block(buf, capacity):
+ buf.push_bytes(value)
- push_bytes(buf, value)
===========changed ref 21===========
# module: aioquic.packet
def push_new_token_frame(buf: Buffer, token: bytes) -> None:
+ buf.push_uint_var(len(token))
- push_uint_var(buf, len(token))
+ buf.push_bytes(token)
- push_bytes(buf, token)
===========changed ref 22===========
# module: aioquic.tls
def pull_opaque(buf: Buffer, capacity: int) -> bytes:
"""
Pull an opaque value prefixed by a length.
"""
with pull_block(buf, capacity) as length:
+ return buf.pull_bytes(length)
- return pull_bytes(buf, length)
|
aioquic.connection/QuicConnection._handle_max_data_frame
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<5>:<add> max_data = buf.pull_uint_var()
<del> max_data = pull_uint_var(buf)
|
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_max_data_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
<0> """
<1> Handle a MAX_DATA frame.
<2>
<3> This adjusts the total amount of we can send to the peer.
<4> """
<5> max_data = pull_uint_var(buf)
<6> if max_data > self._remote_max_data:
<7> self._logger.info("Remote max_data raised to %d", max_data)
<8> self._remote_max_data = max_data
<9>
|
===========unchanged ref 0===========
at: aioquic.buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic.connection
QuicReceiveContext(epoch: tls.Epoch, host_cid: bytes, network_path: QuicNetworkPath, time: float)
at: aioquic.connection.QuicConnection.__init__
self._logger = QuicConnectionAdapter(
logger, {"host_cid": dump_cid(self.host_cid)}
)
self._remote_max_data = 0
at: aioquic.connection.QuicConnection._handle_max_data_frame
max_data = buf.pull_uint_var()
at: logging.LoggerAdapter
logger: Logger
extra: Mapping[str, Any]
info(msg: Any, *args: Any, exc_info: _ExcInfoType=..., stack_info: bool=..., extra: Optional[Dict[str, Any]]=..., **kwargs: Any) -> None
===========changed ref 0===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_data_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a DATA_BLOCKED frame.
"""
+ buf.pull_uint_var() # limit
- pull_uint_var(buf) # limit
===========changed ref 1===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_ack_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle an ACK frame.
"""
ack_rangeset, ack_delay_encoded = pull_ack_frame(buf)
if frame_type == QuicFrameType.ACK_ECN:
+ buf.pull_uint_var()
- pull_uint_var(buf)
+ buf.pull_uint_var()
- pull_uint_var(buf)
+ buf.pull_uint_var()
- pull_uint_var(buf)
self._loss.on_ack_received(
space=self._spaces[context.epoch],
ack_rangeset=ack_rangeset,
ack_delay_encoded=ack_delay_encoded,
now=context.time,
)
# check if we can discard handshake keys
if (
not self._handshake_confirmed
and self._handshake_complete
and context.epoch == tls.Epoch.ONE_RTT
):
self._discard_epoch(tls.Epoch.HANDSHAKE)
self._handshake_confirmed = True
===========changed ref 2===========
# module: aioquic.tls
def pull_group(buf: Buffer) -> Group:
+ return Group(buf.pull_uint16())
- return Group(pull_uint16(buf))
===========changed ref 3===========
# module: aioquic.tls
def pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm:
+ return SignatureAlgorithm(buf.pull_uint16())
- return SignatureAlgorithm(pull_uint16(buf))
===========changed ref 4===========
# module: aioquic.tls
def pull_compression_method(buf: Buffer) -> CompressionMethod:
+ return CompressionMethod(buf.pull_uint8())
- return CompressionMethod(pull_uint8(buf))
===========changed ref 5===========
# module: aioquic.tls
# INTEGERS
def pull_cipher_suite(buf: Buffer) -> CipherSuite:
+ return CipherSuite(buf.pull_uint16())
- return CipherSuite(pull_uint16(buf))
===========changed ref 6===========
# module: aioquic.tls
def pull_key_exchange_mode(buf: Buffer) -> KeyExchangeMode:
+ return KeyExchangeMode(buf.pull_uint8())
- return KeyExchangeMode(pull_uint8(buf))
===========changed ref 7===========
# module: aioquic.buffer
class Buffer:
+ def push_uint8(self, v: int) -> None:
+ """
+ Push an 8-bit unsigned integer.
+ """
+ self._data[self._pos] = v
+ self._pos += 1
+
===========changed ref 8===========
# module: aioquic.tls
def push_key_share(buf: Buffer, value: KeyShareEntry) -> None:
+ buf.push_uint16(value[0])
- push_group(buf, value[0])
push_opaque(buf, 2, value[1])
===========changed ref 9===========
# module: aioquic.tls
@contextmanager
def push_extension(buf: Buffer, extension_type: int) -> Generator:
+ buf.push_uint16(extension_type)
- push_uint16(buf, extension_type)
with push_block(buf, 2):
yield
===========changed ref 10===========
# module: aioquic.buffer
- def push_uint8(buf: Buffer, v: int) -> None:
- """
- Push an 8-bit unsigned integer.
- """
- buf._data[buf._pos] = v
- buf._pos += 1
-
===========changed ref 11===========
# module: aioquic.tls
def push_psk_identity(buf: Buffer, entry: PskIdentity) -> None:
push_opaque(buf, 2, entry[0])
+ buf.push_uint32(entry[1])
- push_uint32(buf, entry[1])
===========changed ref 12===========
# module: aioquic.buffer
class Buffer:
+ def push_uint64(self, v: int) -> None:
+ """
+ Push a 64-bit unsigned integer.
+ """
+ pack_into("!Q", self._data, self._pos, v)
+ self._pos += 8
+
===========changed ref 13===========
# module: aioquic.buffer
class Buffer:
+ def push_uint32(self, v: int) -> None:
+ """
+ Push a 32-bit unsigned integer.
+ """
+ pack_into("!L", self._data, self._pos, v)
+ self._pos += 4
+
===========changed ref 14===========
# module: aioquic.buffer
class Buffer:
+ def push_uint16(self, v: int) -> None:
+ """
+ Push a 16-bit unsigned integer.
+ """
+ pack_into("!H", self._data, self._pos, v)
+ self._pos += 2
+
===========changed ref 15===========
# module: aioquic.tls
def push_list(
+ buf: Buffer, capacity: int, func: Callable[[T], None], values: Sequence[T]
- buf: Buffer, capacity: int, func: Callable[[Buffer, T], None], values: Sequence[T]
) -> None:
"""
Push a list of items.
"""
with push_block(buf, capacity):
for value in values:
+ func(value)
- func(buf, value)
===========changed ref 16===========
# module: aioquic.packet
def pull_new_token_frame(buf: Buffer) -> bytes:
+ length = buf.pull_uint_var()
- length = pull_uint_var(buf)
+ return buf.pull_bytes(length)
- return pull_bytes(buf, length)
===========changed ref 17===========
# module: aioquic.tls
def push_finished(buf: Buffer, finished: Finished) -> None:
+ buf.push_uint8(HandshakeType.FINISHED)
- push_uint8(buf, HandshakeType.FINISHED)
push_opaque(buf, 3, finished.verify_data)
===========changed ref 18===========
# module: aioquic.buffer
- def push_uint64(buf: Buffer, v: int) -> None:
- """
- Push a 64-bit unsigned integer.
- """
- pack_into("!Q", buf._data, buf._pos, v)
- buf._pos += 8
-
===========changed ref 19===========
# module: aioquic.buffer
- def push_uint32(buf: Buffer, v: int) -> None:
- """
- Push a 32-bit unsigned integer.
- """
- pack_into("!L", buf._data, buf._pos, v)
- buf._pos += 4
-
|
aioquic.connection/QuicConnection._handle_max_stream_data_frame
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<5>:<add> stream_id = buf.pull_uint_var()
<del> stream_id = pull_uint_var(buf)
<6>:<add> max_stream_data = buf.pull_uint_var()
<del> max_stream_data = pull_uint_var(buf)
|
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_max_stream_data_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
<0> """
<1> Handle a MAX_STREAM_DATA frame.
<2>
<3> This adjusts the amount of data we can send on a specific stream.
<4> """
<5> stream_id = pull_uint_var(buf)
<6> max_stream_data = pull_uint_var(buf)
<7>
<8> # check stream direction
<9> self._assert_stream_can_send(frame_type, stream_id)
<10>
<11> stream = self._get_or_create_stream(frame_type, stream_id)
<12> if max_stream_data > stream.max_stream_data_remote:
<13> self._logger.info(
<14> "Stream %d remote max_stream_data raised to %d",
<15> stream_id,
<16> max_stream_data,
<17> )
<18> stream.max_stream_data_remote = max_stream_data
<19>
|
===========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.connection
QuicReceiveContext(epoch: tls.Epoch, host_cid: bytes, network_path: QuicNetworkPath, time: float)
at: aioquic.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.connection.QuicConnection.__init__
self._logger = QuicConnectionAdapter(
logger, {"host_cid": dump_cid(self.host_cid)}
)
at: aioquic.connection.QuicConnection._handle_max_stream_data_frame
stream_id = buf.pull_uint_var()
at: aioquic.stream.QuicStream.__init__
self.max_stream_data_remote = max_stream_data_remote
at: logging.LoggerAdapter
info(msg: Any, *args: Any, exc_info: _ExcInfoType=..., stack_info: bool=..., extra: Optional[Dict[str, Any]]=..., **kwargs: Any) -> None
===========changed ref 0===========
# module: aioquic.buffer
class Buffer:
+ def pull_uint_var(self) -> int:
+ """
+ Pull a QUIC variable-length unsigned integer.
+ """
+ try:
+ kind = self._data[self._pos] // 64
+ if kind == 0:
+ value = self._data[self._pos]
+ self._pos += 1
+ return value
+ elif kind == 1:
+ value, = unpack_from("!H", self._data, self._pos)
+ self._pos += 2
+ return value & 0x3FFF
+ elif kind == 2:
+ value, = unpack_from("!L", self._data, self._pos)
+ self._pos += 4
+ return value & 0x3FFFFFFF
+ else:
+ value, = unpack_from("!Q", self._data, self._pos)
+ self._pos += 8
+ return value & 0x3FFFFFFFFFFFFFFF
+ except (IndexError, struct.error):
+ raise BufferReadError
+
===========changed ref 1===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_data_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a DATA_BLOCKED frame.
"""
+ buf.pull_uint_var() # limit
- pull_uint_var(buf) # limit
===========changed ref 2===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- max_data = pull_uint_var(buf)
if max_data > self._remote_max_data:
self._logger.info("Remote max_data raised to %d", max_data)
self._remote_max_data = max_data
===========changed ref 3===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_ack_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle an ACK frame.
"""
ack_rangeset, ack_delay_encoded = pull_ack_frame(buf)
if frame_type == QuicFrameType.ACK_ECN:
+ buf.pull_uint_var()
- pull_uint_var(buf)
+ buf.pull_uint_var()
- pull_uint_var(buf)
+ buf.pull_uint_var()
- pull_uint_var(buf)
self._loss.on_ack_received(
space=self._spaces[context.epoch],
ack_rangeset=ack_rangeset,
ack_delay_encoded=ack_delay_encoded,
now=context.time,
)
# check if we can discard handshake keys
if (
not self._handshake_confirmed
and self._handshake_complete
and context.epoch == tls.Epoch.ONE_RTT
):
self._discard_epoch(tls.Epoch.HANDSHAKE)
self._handshake_confirmed = True
===========changed ref 4===========
# module: aioquic.tls
def pull_group(buf: Buffer) -> Group:
+ return Group(buf.pull_uint16())
- return Group(pull_uint16(buf))
===========changed ref 5===========
# module: aioquic.tls
def pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm:
+ return SignatureAlgorithm(buf.pull_uint16())
- return SignatureAlgorithm(pull_uint16(buf))
===========changed ref 6===========
# module: aioquic.tls
def pull_compression_method(buf: Buffer) -> CompressionMethod:
+ return CompressionMethod(buf.pull_uint8())
- return CompressionMethod(pull_uint8(buf))
===========changed ref 7===========
# module: aioquic.tls
# INTEGERS
def pull_cipher_suite(buf: Buffer) -> CipherSuite:
+ return CipherSuite(buf.pull_uint16())
- return CipherSuite(pull_uint16(buf))
===========changed ref 8===========
# module: aioquic.tls
def pull_key_exchange_mode(buf: Buffer) -> KeyExchangeMode:
+ return KeyExchangeMode(buf.pull_uint8())
- return KeyExchangeMode(pull_uint8(buf))
===========changed ref 9===========
# module: aioquic.buffer
class Buffer:
+ def push_uint8(self, v: int) -> None:
+ """
+ Push an 8-bit unsigned integer.
+ """
+ self._data[self._pos] = v
+ self._pos += 1
+
===========changed ref 10===========
# module: aioquic.tls
def push_key_share(buf: Buffer, value: KeyShareEntry) -> None:
+ buf.push_uint16(value[0])
- push_group(buf, value[0])
push_opaque(buf, 2, value[1])
===========changed ref 11===========
# module: aioquic.tls
@contextmanager
def push_extension(buf: Buffer, extension_type: int) -> Generator:
+ buf.push_uint16(extension_type)
- push_uint16(buf, extension_type)
with push_block(buf, 2):
yield
===========changed ref 12===========
# module: aioquic.buffer
- def push_uint8(buf: Buffer, v: int) -> None:
- """
- Push an 8-bit unsigned integer.
- """
- buf._data[buf._pos] = v
- buf._pos += 1
-
===========changed ref 13===========
# module: aioquic.tls
def push_psk_identity(buf: Buffer, entry: PskIdentity) -> None:
push_opaque(buf, 2, entry[0])
+ buf.push_uint32(entry[1])
- push_uint32(buf, entry[1])
===========changed ref 14===========
# module: aioquic.buffer
class Buffer:
+ def push_uint64(self, v: int) -> None:
+ """
+ Push a 64-bit unsigned integer.
+ """
+ pack_into("!Q", self._data, self._pos, v)
+ self._pos += 8
+
===========changed ref 15===========
# module: aioquic.buffer
class Buffer:
+ def push_uint32(self, v: int) -> None:
+ """
+ Push a 32-bit unsigned integer.
+ """
+ pack_into("!L", self._data, self._pos, v)
+ self._pos += 4
+
|
aioquic.connection/QuicConnection._handle_max_streams_bidi_frame
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<5>:<add> max_streams = buf.pull_uint_var()
<del> max_streams = pull_uint_var(buf)
|
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_max_streams_bidi_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
<0> """
<1> Handle a MAX_STREAMS_BIDI frame.
<2>
<3> This raises number of bidirectional streams we can initiate to the peer.
<4> """
<5> max_streams = pull_uint_var(buf)
<6> if max_streams > self._remote_max_streams_bidi:
<7> self._logger.info("Remote max_streams_bidi raised to %d", max_streams)
<8> self._remote_max_streams_bidi = max_streams
<9>
|
===========unchanged ref 0===========
at: aioquic.buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic.connection
QuicReceiveContext(epoch: tls.Epoch, host_cid: bytes, network_path: QuicNetworkPath, time: float)
at: aioquic.connection.QuicConnection.__init__
self._logger = QuicConnectionAdapter(
logger, {"host_cid": dump_cid(self.host_cid)}
)
self._remote_max_streams_bidi = 0
at: aioquic.connection.QuicConnection._handle_max_streams_bidi_frame
max_streams = buf.pull_uint_var()
at: logging.LoggerAdapter
info(msg: Any, *args: Any, exc_info: _ExcInfoType=..., stack_info: bool=..., extra: Optional[Dict[str, Any]]=..., **kwargs: Any) -> None
===========changed ref 0===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_data_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a DATA_BLOCKED frame.
"""
+ buf.pull_uint_var() # limit
- pull_uint_var(buf) # limit
===========changed ref 1===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- max_data = pull_uint_var(buf)
if max_data > self._remote_max_data:
self._logger.info("Remote max_data raised to %d", max_data)
self._remote_max_data = max_data
===========changed ref 2===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- stream_id = pull_uint_var(buf)
+ max_stream_data = buf.pull_uint_var()
- max_stream_data = pull_uint_var(buf)
# 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.info(
"Stream %d remote max_stream_data raised to %d",
stream_id,
max_stream_data,
)
stream.max_stream_data_remote = max_stream_data
===========changed ref 3===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_ack_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle an ACK frame.
"""
ack_rangeset, ack_delay_encoded = pull_ack_frame(buf)
if frame_type == QuicFrameType.ACK_ECN:
+ buf.pull_uint_var()
- pull_uint_var(buf)
+ buf.pull_uint_var()
- pull_uint_var(buf)
+ buf.pull_uint_var()
- pull_uint_var(buf)
self._loss.on_ack_received(
space=self._spaces[context.epoch],
ack_rangeset=ack_rangeset,
ack_delay_encoded=ack_delay_encoded,
now=context.time,
)
# check if we can discard handshake keys
if (
not self._handshake_confirmed
and self._handshake_complete
and context.epoch == tls.Epoch.ONE_RTT
):
self._discard_epoch(tls.Epoch.HANDSHAKE)
self._handshake_confirmed = True
===========changed ref 4===========
# module: aioquic.tls
def pull_group(buf: Buffer) -> Group:
+ return Group(buf.pull_uint16())
- return Group(pull_uint16(buf))
===========changed ref 5===========
# module: aioquic.tls
def pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm:
+ return SignatureAlgorithm(buf.pull_uint16())
- return SignatureAlgorithm(pull_uint16(buf))
===========changed ref 6===========
# module: aioquic.tls
def pull_compression_method(buf: Buffer) -> CompressionMethod:
+ return CompressionMethod(buf.pull_uint8())
- return CompressionMethod(pull_uint8(buf))
===========changed ref 7===========
# module: aioquic.tls
# INTEGERS
def pull_cipher_suite(buf: Buffer) -> CipherSuite:
+ return CipherSuite(buf.pull_uint16())
- return CipherSuite(pull_uint16(buf))
===========changed ref 8===========
# module: aioquic.tls
def pull_key_exchange_mode(buf: Buffer) -> KeyExchangeMode:
+ return KeyExchangeMode(buf.pull_uint8())
- return KeyExchangeMode(pull_uint8(buf))
===========changed ref 9===========
# module: aioquic.buffer
class Buffer:
+ def push_uint8(self, v: int) -> None:
+ """
+ Push an 8-bit unsigned integer.
+ """
+ self._data[self._pos] = v
+ self._pos += 1
+
===========changed ref 10===========
# module: aioquic.tls
def push_key_share(buf: Buffer, value: KeyShareEntry) -> None:
+ buf.push_uint16(value[0])
- push_group(buf, value[0])
push_opaque(buf, 2, value[1])
===========changed ref 11===========
# module: aioquic.tls
@contextmanager
def push_extension(buf: Buffer, extension_type: int) -> Generator:
+ buf.push_uint16(extension_type)
- push_uint16(buf, extension_type)
with push_block(buf, 2):
yield
===========changed ref 12===========
# module: aioquic.buffer
- def push_uint8(buf: Buffer, v: int) -> None:
- """
- Push an 8-bit unsigned integer.
- """
- buf._data[buf._pos] = v
- buf._pos += 1
-
===========changed ref 13===========
# module: aioquic.tls
def push_psk_identity(buf: Buffer, entry: PskIdentity) -> None:
push_opaque(buf, 2, entry[0])
+ buf.push_uint32(entry[1])
- push_uint32(buf, entry[1])
===========changed ref 14===========
# module: aioquic.buffer
class Buffer:
+ def push_uint64(self, v: int) -> None:
+ """
+ Push a 64-bit unsigned integer.
+ """
+ pack_into("!Q", self._data, self._pos, v)
+ self._pos += 8
+
===========changed ref 15===========
# module: aioquic.buffer
class Buffer:
+ def push_uint32(self, v: int) -> None:
+ """
+ Push a 32-bit unsigned integer.
+ """
+ pack_into("!L", self._data, self._pos, v)
+ self._pos += 4
+
===========changed ref 16===========
# module: aioquic.buffer
class Buffer:
+ def push_uint16(self, v: int) -> None:
+ """
+ Push a 16-bit unsigned integer.
+ """
+ pack_into("!H", self._data, self._pos, v)
+ self._pos += 2
+
|
aioquic.connection/QuicConnection._handle_max_streams_uni_frame
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<5>:<add> max_streams = buf.pull_uint_var()
<del> max_streams = pull_uint_var(buf)
|
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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 = pull_uint_var(buf)
<6> if max_streams > self._remote_max_streams_uni:
<7> self._logger.info("Remote max_streams_uni raised to %d", max_streams)
<8> self._remote_max_streams_uni = max_streams
<9>
|
===========unchanged ref 0===========
at: aioquic.buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic.connection
QuicReceiveContext(epoch: tls.Epoch, host_cid: bytes, network_path: QuicNetworkPath, time: float)
at: aioquic.connection.QuicConnection.__init__
self._logger = QuicConnectionAdapter(
logger, {"host_cid": dump_cid(self.host_cid)}
)
self._remote_max_streams_uni = 0
at: aioquic.connection.QuicConnection._handle_max_streams_uni_frame
max_streams = buf.pull_uint_var()
at: aioquic.packet
pull_new_connection_id_frame(buf: Buffer) -> Tuple[int, bytes, bytes]
at: logging.LoggerAdapter
info(msg: Any, *args: Any, exc_info: _ExcInfoType=..., stack_info: bool=..., extra: Optional[Dict[str, Any]]=..., **kwargs: Any) -> None
===========changed ref 0===========
# module: aioquic.packet
def pull_new_connection_id_frame(buf: Buffer) -> Tuple[int, bytes, bytes]:
+ sequence_number = buf.pull_uint_var()
- sequence_number = pull_uint_var(buf)
+ length = buf.pull_uint8()
- length = pull_uint8(buf)
+ connection_id = buf.pull_bytes(length)
- connection_id = pull_bytes(buf, length)
+ stateless_reset_token = buf.pull_bytes(16)
- stateless_reset_token = pull_bytes(buf, 16)
return (sequence_number, connection_id, stateless_reset_token)
===========changed ref 1===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_data_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a DATA_BLOCKED frame.
"""
+ buf.pull_uint_var() # limit
- pull_uint_var(buf) # limit
===========changed ref 2===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- max_streams = pull_uint_var(buf)
if max_streams > self._remote_max_streams_bidi:
self._logger.info("Remote max_streams_bidi raised to %d", max_streams)
self._remote_max_streams_bidi = max_streams
===========changed ref 3===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- max_data = pull_uint_var(buf)
if max_data > self._remote_max_data:
self._logger.info("Remote max_data raised to %d", max_data)
self._remote_max_data = max_data
===========changed ref 4===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- stream_id = pull_uint_var(buf)
+ max_stream_data = buf.pull_uint_var()
- max_stream_data = pull_uint_var(buf)
# 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.info(
"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.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_ack_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle an ACK frame.
"""
ack_rangeset, ack_delay_encoded = pull_ack_frame(buf)
if frame_type == QuicFrameType.ACK_ECN:
+ buf.pull_uint_var()
- pull_uint_var(buf)
+ buf.pull_uint_var()
- pull_uint_var(buf)
+ buf.pull_uint_var()
- pull_uint_var(buf)
self._loss.on_ack_received(
space=self._spaces[context.epoch],
ack_rangeset=ack_rangeset,
ack_delay_encoded=ack_delay_encoded,
now=context.time,
)
# check if we can discard handshake keys
if (
not self._handshake_confirmed
and self._handshake_complete
and context.epoch == tls.Epoch.ONE_RTT
):
self._discard_epoch(tls.Epoch.HANDSHAKE)
self._handshake_confirmed = True
===========changed ref 6===========
# module: aioquic.tls
def pull_group(buf: Buffer) -> Group:
+ return Group(buf.pull_uint16())
- return Group(pull_uint16(buf))
===========changed ref 7===========
# module: aioquic.tls
def pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm:
+ return SignatureAlgorithm(buf.pull_uint16())
- return SignatureAlgorithm(pull_uint16(buf))
===========changed ref 8===========
# module: aioquic.tls
def pull_compression_method(buf: Buffer) -> CompressionMethod:
+ return CompressionMethod(buf.pull_uint8())
- return CompressionMethod(pull_uint8(buf))
===========changed ref 9===========
# module: aioquic.tls
# INTEGERS
def pull_cipher_suite(buf: Buffer) -> CipherSuite:
+ return CipherSuite(buf.pull_uint16())
- return CipherSuite(pull_uint16(buf))
===========changed ref 10===========
# module: aioquic.tls
def pull_key_exchange_mode(buf: Buffer) -> KeyExchangeMode:
+ return KeyExchangeMode(buf.pull_uint8())
- return KeyExchangeMode(pull_uint8(buf))
===========changed ref 11===========
# module: aioquic.buffer
class Buffer:
+ def push_uint8(self, v: int) -> None:
+ """
+ Push an 8-bit unsigned integer.
+ """
+ self._data[self._pos] = v
+ self._pos += 1
+
===========changed ref 12===========
# module: aioquic.tls
def push_key_share(buf: Buffer, value: KeyShareEntry) -> None:
+ buf.push_uint16(value[0])
- push_group(buf, value[0])
push_opaque(buf, 2, value[1])
===========changed ref 13===========
# module: aioquic.tls
@contextmanager
def push_extension(buf: Buffer, extension_type: int) -> Generator:
+ buf.push_uint16(extension_type)
- push_uint16(buf, extension_type)
with push_block(buf, 2):
yield
|
aioquic.connection/QuicConnection._handle_path_challenge_frame
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<3>:<add> data = buf.pull_bytes(8)
<del> data = pull_bytes(buf, 8)
|
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_path_challenge_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
<0> """
<1> Handle a PATH_CHALLENGE frame.
<2> """
<3> data = pull_bytes(buf, 8)
<4> context.network_path.remote_challenge = data
<5>
|
===========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.connection
QuicReceiveContext(epoch: tls.Epoch, host_cid: bytes, network_path: QuicNetworkPath, time: float)
at: aioquic.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.connection.QuicReceiveContext
network_path: QuicNetworkPath
===========changed ref 0===========
# module: aioquic.buffer
class Buffer:
+ def pull_bytes(self, length: int) -> bytes:
+ """
+ Pull bytes.
+ """
+ end = self._pos + length
+ if end > self._length:
+ raise BufferReadError
+ v = bytes(self._data[self._pos : end])
+ self._pos = end
+ return v
+
===========changed ref 1===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_data_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a DATA_BLOCKED frame.
"""
+ buf.pull_uint_var() # limit
- pull_uint_var(buf) # limit
===========changed ref 2===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- max_streams = pull_uint_var(buf)
if max_streams > self._remote_max_streams_uni:
self._logger.info("Remote max_streams_uni raised to %d", max_streams)
self._remote_max_streams_uni = max_streams
===========changed ref 3===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- max_streams = pull_uint_var(buf)
if max_streams > self._remote_max_streams_bidi:
self._logger.info("Remote max_streams_bidi raised to %d", max_streams)
self._remote_max_streams_bidi = max_streams
===========changed ref 4===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- max_data = pull_uint_var(buf)
if max_data > self._remote_max_data:
self._logger.info("Remote max_data raised to %d", max_data)
self._remote_max_data = max_data
===========changed ref 5===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- stream_id = pull_uint_var(buf)
+ max_stream_data = buf.pull_uint_var()
- max_stream_data = pull_uint_var(buf)
# 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.info(
"Stream %d remote max_stream_data raised to %d",
stream_id,
max_stream_data,
)
stream.max_stream_data_remote = max_stream_data
===========changed ref 6===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_ack_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle an ACK frame.
"""
ack_rangeset, ack_delay_encoded = pull_ack_frame(buf)
if frame_type == QuicFrameType.ACK_ECN:
+ buf.pull_uint_var()
- pull_uint_var(buf)
+ buf.pull_uint_var()
- pull_uint_var(buf)
+ buf.pull_uint_var()
- pull_uint_var(buf)
self._loss.on_ack_received(
space=self._spaces[context.epoch],
ack_rangeset=ack_rangeset,
ack_delay_encoded=ack_delay_encoded,
now=context.time,
)
# check if we can discard handshake keys
if (
not self._handshake_confirmed
and self._handshake_complete
and context.epoch == tls.Epoch.ONE_RTT
):
self._discard_epoch(tls.Epoch.HANDSHAKE)
self._handshake_confirmed = True
===========changed ref 7===========
# module: aioquic.tls
def pull_group(buf: Buffer) -> Group:
+ return Group(buf.pull_uint16())
- return Group(pull_uint16(buf))
===========changed ref 8===========
# module: aioquic.tls
def pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm:
+ return SignatureAlgorithm(buf.pull_uint16())
- return SignatureAlgorithm(pull_uint16(buf))
===========changed ref 9===========
# module: aioquic.tls
def pull_compression_method(buf: Buffer) -> CompressionMethod:
+ return CompressionMethod(buf.pull_uint8())
- return CompressionMethod(pull_uint8(buf))
===========changed ref 10===========
# module: aioquic.tls
# INTEGERS
def pull_cipher_suite(buf: Buffer) -> CipherSuite:
+ return CipherSuite(buf.pull_uint16())
- return CipherSuite(pull_uint16(buf))
===========changed ref 11===========
# module: aioquic.tls
def pull_key_exchange_mode(buf: Buffer) -> KeyExchangeMode:
+ return KeyExchangeMode(buf.pull_uint8())
- return KeyExchangeMode(pull_uint8(buf))
===========changed ref 12===========
# module: aioquic.buffer
class Buffer:
+ def push_uint8(self, v: int) -> None:
+ """
+ Push an 8-bit unsigned integer.
+ """
+ self._data[self._pos] = v
+ self._pos += 1
+
===========changed ref 13===========
# module: aioquic.tls
def push_key_share(buf: Buffer, value: KeyShareEntry) -> None:
+ buf.push_uint16(value[0])
- push_group(buf, value[0])
push_opaque(buf, 2, value[1])
|
aioquic.connection/QuicConnection._handle_path_response_frame
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<3>:<add> data = buf.pull_bytes(8)
<del> data = pull_bytes(buf, 8)
|
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_path_response_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
<0> """
<1> Handle a PATH_RESPONSE frame.
<2> """
<3> data = pull_bytes(buf, 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.buffer.Buffer
pull_uint16() -> int
pull_uint_var() -> int
at: aioquic.connection
QuicReceiveContext(epoch: tls.Epoch, host_cid: bytes, network_path: QuicNetworkPath, time: float)
at: aioquic.connection.QuicConnection.__init__
self._logger = QuicConnectionAdapter(
logger, {"host_cid": dump_cid(self.host_cid)}
)
at: aioquic.connection.QuicNetworkPath
addr: NetworkAddress
is_validated: bool = False
at: aioquic.connection.QuicReceiveContext
network_path: QuicNetworkPath
at: aioquic.packet
QuicErrorCode(x: Union[str, bytes, bytearray], base: int)
QuicErrorCode(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
at: logging.LoggerAdapter
info(msg: Any, *args: Any, exc_info: _ExcInfoType=..., stack_info: bool=..., extra: Optional[Dict[str, Any]]=..., **kwargs: Any) -> None
===========changed ref 0===========
# module: aioquic.buffer
class Buffer:
+ def pull_uint16(self) -> int:
+ """
+ Pull a 16-bit unsigned integer.
+ """
+ try:
+ v, = struct.unpack_from("!H", self._data, self._pos)
+ self._pos += 2
+ return v
+ except struct.error:
+ raise BufferReadError
+
===========changed ref 1===========
# module: aioquic.buffer
class Buffer:
+ def pull_uint_var(self) -> int:
+ """
+ Pull a QUIC variable-length unsigned integer.
+ """
+ try:
+ kind = self._data[self._pos] // 64
+ if kind == 0:
+ value = self._data[self._pos]
+ self._pos += 1
+ return value
+ elif kind == 1:
+ value, = unpack_from("!H", self._data, self._pos)
+ self._pos += 2
+ return value & 0x3FFF
+ elif kind == 2:
+ value, = unpack_from("!L", self._data, self._pos)
+ self._pos += 4
+ return value & 0x3FFFFFFF
+ else:
+ value, = unpack_from("!Q", self._data, self._pos)
+ self._pos += 8
+ return value & 0x3FFFFFFFFFFFFFFF
+ except (IndexError, struct.error):
+ raise BufferReadError
+
===========changed ref 2===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_path_challenge_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a PATH_CHALLENGE frame.
"""
+ data = buf.pull_bytes(8)
- data = pull_bytes(buf, 8)
context.network_path.remote_challenge = data
===========changed ref 3===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_data_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a DATA_BLOCKED frame.
"""
+ buf.pull_uint_var() # limit
- pull_uint_var(buf) # limit
===========changed ref 4===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- max_streams = pull_uint_var(buf)
if max_streams > self._remote_max_streams_uni:
self._logger.info("Remote max_streams_uni raised to %d", max_streams)
self._remote_max_streams_uni = max_streams
===========changed ref 5===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- max_streams = pull_uint_var(buf)
if max_streams > self._remote_max_streams_bidi:
self._logger.info("Remote max_streams_bidi raised to %d", max_streams)
self._remote_max_streams_bidi = max_streams
===========changed ref 6===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- max_data = pull_uint_var(buf)
if max_data > self._remote_max_data:
self._logger.info("Remote max_data raised to %d", max_data)
self._remote_max_data = max_data
===========changed ref 7===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- stream_id = pull_uint_var(buf)
+ max_stream_data = buf.pull_uint_var()
- max_stream_data = pull_uint_var(buf)
# 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.info(
"Stream %d remote max_stream_data raised to %d",
stream_id,
max_stream_data,
)
stream.max_stream_data_remote = max_stream_data
|
aioquic.connection/QuicConnection._handle_reset_stream_frame
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<3>:<add> stream_id = buf.pull_uint_var()
<del> stream_id = pull_uint_var(buf)
<4>:<add> error_code = buf.pull_uint16()
<del> error_code = pull_uint16(buf)
<5>:<add> final_size = buf.pull_uint_var()
<del> final_size = pull_uint_var(buf)
|
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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 = pull_uint_var(buf)
<4> error_code = pull_uint16(buf)
<5> final_size = pull_uint_var(buf)
<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> stream.connection_lost(None)
<18>
|
===========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.connection
QuicReceiveContext(epoch: tls.Epoch, host_cid: bytes, network_path: QuicNetworkPath, time: float)
at: aioquic.connection.QuicConnection
_assert_stream_can_receive(frame_type: int, stream_id: int) -> None
_get_or_create_stream(frame_type: int, stream_id: int) -> QuicStream
at: aioquic.connection.QuicConnection.__init__
self._logger = QuicConnectionAdapter(
logger, {"host_cid": dump_cid(self.host_cid)}
)
at: aioquic.connection.QuicConnection._handle_reset_stream_frame
stream_id = buf.pull_uint_var()
error_code = buf.pull_uint16()
final_size = buf.pull_uint_var()
at: aioquic.stream.QuicStream
connection_lost(exc: Exception) -> None
at: logging.LoggerAdapter
info(msg: Any, *args: Any, exc_info: _ExcInfoType=..., stack_info: bool=..., extra: Optional[Dict[str, Any]]=..., **kwargs: Any) -> None
===========changed ref 0===========
# module: aioquic.buffer
class Buffer:
+ def pull_uint_var(self) -> int:
+ """
+ Pull a QUIC variable-length unsigned integer.
+ """
+ try:
+ kind = self._data[self._pos] // 64
+ if kind == 0:
+ value = self._data[self._pos]
+ self._pos += 1
+ return value
+ elif kind == 1:
+ value, = unpack_from("!H", self._data, self._pos)
+ self._pos += 2
+ return value & 0x3FFF
+ elif kind == 2:
+ value, = unpack_from("!L", self._data, self._pos)
+ self._pos += 4
+ return value & 0x3FFFFFFF
+ else:
+ value, = unpack_from("!Q", self._data, self._pos)
+ self._pos += 8
+ return value & 0x3FFFFFFFFFFFFFFF
+ except (IndexError, struct.error):
+ raise BufferReadError
+
===========changed ref 1===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_path_challenge_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a PATH_CHALLENGE frame.
"""
+ data = buf.pull_bytes(8)
- data = pull_bytes(buf, 8)
context.network_path.remote_challenge = data
===========changed ref 2===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_path_response_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a PATH_RESPONSE frame.
"""
+ data = buf.pull_bytes(8)
- data = pull_bytes(buf, 8)
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 3===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_data_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a DATA_BLOCKED frame.
"""
+ buf.pull_uint_var() # limit
- pull_uint_var(buf) # limit
===========changed ref 4===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- max_streams = pull_uint_var(buf)
if max_streams > self._remote_max_streams_uni:
self._logger.info("Remote max_streams_uni raised to %d", max_streams)
self._remote_max_streams_uni = max_streams
===========changed ref 5===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- max_streams = pull_uint_var(buf)
if max_streams > self._remote_max_streams_bidi:
self._logger.info("Remote max_streams_bidi raised to %d", max_streams)
self._remote_max_streams_bidi = max_streams
===========changed ref 6===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- max_data = pull_uint_var(buf)
if max_data > self._remote_max_data:
self._logger.info("Remote max_data raised to %d", max_data)
self._remote_max_data = max_data
===========changed ref 7===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- stream_id = pull_uint_var(buf)
+ max_stream_data = buf.pull_uint_var()
- max_stream_data = pull_uint_var(buf)
# 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.info(
"Stream %d remote max_stream_data raised to %d",
stream_id,
max_stream_data,
)
stream.max_stream_data_remote = max_stream_data
|
aioquic.connection/QuicConnection._handle_retire_connection_id_frame
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<3>:<add> sequence_number = buf.pull_uint_var()
<del> sequence_number = pull_uint_var(buf)
|
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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 = pull_uint_var(buf)
<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._connection_id_retired_handler(connection_id.cid)
<16> break
<17>
<18> # issue a new connection ID
<19> self._replenish_connection_ids()
<20>
|
===========unchanged ref 0===========
at: aioquic.buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic.buffer.Buffer
pull_uint16() -> int
pull_uint_var() -> int
at: aioquic.connection
QuicConnectionError(error_code: int, frame_type: int, reason_phrase: str)
QuicReceiveContext(epoch: tls.Epoch, host_cid: bytes, network_path: QuicNetworkPath, time: float)
at: aioquic.connection.QuicConnection
_replenish_connection_ids() -> None
_replenish_connection_ids(self) -> None
at: aioquic.connection.QuicConnection.__init__
self._host_cids = [
QuicConnectionId(
cid=os.urandom(8),
sequence_number=0,
stateless_reset_token=os.urandom(16),
was_sent=True,
)
]
self._connection_id_retired_handler: QuicConnectionIdHandler = lambda c: None
at: aioquic.connection.QuicConnection._handle_retire_connection_id_frame
sequence_number = buf.pull_uint_var()
at: aioquic.connection.QuicConnectionId
cid: bytes
sequence_number: int
stateless_reset_token: bytes = b""
was_sent: bool = False
at: aioquic.connection.QuicReceiveContext
host_cid: bytes
at: aioquic.packet
QuicErrorCode(x: Union[str, bytes, bytearray], base: int)
QuicErrorCode(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
===========changed ref 0===========
# module: aioquic.buffer
class Buffer:
+ def pull_uint16(self) -> int:
+ """
+ Pull a 16-bit unsigned integer.
+ """
+ try:
+ v, = struct.unpack_from("!H", self._data, self._pos)
+ self._pos += 2
+ return v
+ except struct.error:
+ raise BufferReadError
+
===========changed ref 1===========
# module: aioquic.buffer
class Buffer:
+ def pull_uint_var(self) -> int:
+ """
+ Pull a QUIC variable-length unsigned integer.
+ """
+ try:
+ kind = self._data[self._pos] // 64
+ if kind == 0:
+ value = self._data[self._pos]
+ self._pos += 1
+ return value
+ elif kind == 1:
+ value, = unpack_from("!H", self._data, self._pos)
+ self._pos += 2
+ return value & 0x3FFF
+ elif kind == 2:
+ value, = unpack_from("!L", self._data, self._pos)
+ self._pos += 4
+ return value & 0x3FFFFFFF
+ else:
+ value, = unpack_from("!Q", self._data, self._pos)
+ self._pos += 8
+ return value & 0x3FFFFFFFFFFFFFFF
+ except (IndexError, struct.error):
+ raise BufferReadError
+
===========changed ref 2===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_path_challenge_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a PATH_CHALLENGE frame.
"""
+ data = buf.pull_bytes(8)
- data = pull_bytes(buf, 8)
context.network_path.remote_challenge = data
===========changed ref 3===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_path_response_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a PATH_RESPONSE frame.
"""
+ data = buf.pull_bytes(8)
- data = pull_bytes(buf, 8)
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.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_data_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a DATA_BLOCKED frame.
"""
+ buf.pull_uint_var() # limit
- pull_uint_var(buf) # limit
===========changed ref 5===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- max_streams = pull_uint_var(buf)
if max_streams > self._remote_max_streams_uni:
self._logger.info("Remote max_streams_uni raised to %d", max_streams)
self._remote_max_streams_uni = max_streams
===========changed ref 6===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- stream_id = pull_uint_var(buf)
+ error_code = buf.pull_uint16()
- error_code = pull_uint16(buf)
+ final_size = buf.pull_uint_var()
- final_size = pull_uint_var(buf)
# 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)
stream.connection_lost(None)
===========changed ref 7===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- max_streams = pull_uint_var(buf)
if max_streams > self._remote_max_streams_bidi:
self._logger.info("Remote max_streams_bidi raised to %d", max_streams)
self._remote_max_streams_bidi = max_streams
|
aioquic.connection/QuicConnection._handle_stop_sending_frame
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<3>:<add> stream_id = buf.pull_uint_var()
<del> stream_id = pull_uint_var(buf)
<4>:<add> buf.pull_uint16() # application error code
<del> pull_uint16(buf) # application error code
|
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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 = pull_uint_var(buf)
<4> pull_uint16(buf) # 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.connection
QuicReceiveContext(epoch: tls.Epoch, host_cid: bytes, network_path: QuicNetworkPath, time: float)
at: aioquic.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.connection.QuicConnection._handle_stop_sending_frame
stream_id = buf.pull_uint_var()
===========changed ref 0===========
# module: aioquic.buffer
class Buffer:
+ def pull_uint_var(self) -> int:
+ """
+ Pull a QUIC variable-length unsigned integer.
+ """
+ try:
+ kind = self._data[self._pos] // 64
+ if kind == 0:
+ value = self._data[self._pos]
+ self._pos += 1
+ return value
+ elif kind == 1:
+ value, = unpack_from("!H", self._data, self._pos)
+ self._pos += 2
+ return value & 0x3FFF
+ elif kind == 2:
+ value, = unpack_from("!L", self._data, self._pos)
+ self._pos += 4
+ return value & 0x3FFFFFFF
+ else:
+ value, = unpack_from("!Q", self._data, self._pos)
+ self._pos += 8
+ return value & 0x3FFFFFFFFFFFFFFF
+ except (IndexError, struct.error):
+ raise BufferReadError
+
===========changed ref 1===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_path_challenge_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a PATH_CHALLENGE frame.
"""
+ data = buf.pull_bytes(8)
- data = pull_bytes(buf, 8)
context.network_path.remote_challenge = data
===========changed ref 2===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_path_response_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a PATH_RESPONSE frame.
"""
+ data = buf.pull_bytes(8)
- data = pull_bytes(buf, 8)
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 3===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- sequence_number = pull_uint_var(buf)
# 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._connection_id_retired_handler(connection_id.cid)
break
# issue a new connection ID
self._replenish_connection_ids()
===========changed ref 4===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_data_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a DATA_BLOCKED frame.
"""
+ buf.pull_uint_var() # limit
- pull_uint_var(buf) # limit
===========changed ref 5===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- max_streams = pull_uint_var(buf)
if max_streams > self._remote_max_streams_uni:
self._logger.info("Remote max_streams_uni raised to %d", max_streams)
self._remote_max_streams_uni = max_streams
===========changed ref 6===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- stream_id = pull_uint_var(buf)
+ error_code = buf.pull_uint16()
- error_code = pull_uint16(buf)
+ final_size = buf.pull_uint_var()
- final_size = pull_uint_var(buf)
# 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)
stream.connection_lost(None)
===========changed ref 7===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- max_streams = pull_uint_var(buf)
if max_streams > self._remote_max_streams_bidi:
self._logger.info("Remote max_streams_bidi raised to %d", max_streams)
self._remote_max_streams_bidi = max_streams
===========changed ref 8===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- max_data = pull_uint_var(buf)
if max_data > self._remote_max_data:
self._logger.info("Remote max_data raised to %d", max_data)
self._remote_max_data = max_data
|
aioquic.connection/QuicConnection._handle_stream_frame
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<3>:<add> stream_id = buf.pull_uint_var()
<del> stream_id = pull_uint_var(buf)
<5>:<add> offset = buf.pull_uint_var()
<del> offset = pull_uint_var(buf)
<9>:<add> length = buf.pull_uint_var()
<del> length = pull_uint_var(buf)
<13>:<add> offset=offset, data=buf.pull_bytes(length), fin=bool(frame_type & 1)
<del> offset=offset, data=pull_bytes(buf, length), fin=bool(frame_type & 1)
|
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_stream_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
<0> """
<1> Handle a STREAM frame.
<2> """
<3> stream_id = pull_uint_var(buf)
<4> if frame_type & 4:
<5> offset = pull_uint_var(buf)
<6> else:
<7> offset = 0
<8> if frame_type & 2:
<9> length = pull_uint_var(buf)
<10> else:
<11> length = buf.capacity - buf.tell()
<12> frame = QuicStreamFrame(
<13> offset=offset, data=pull_bytes(buf, length), fin=bool(frame_type & 1)
<14> )
<15>
<16> # check stream direction
<17> self._assert_stream_can_receive(frame_type, stream_id)
<18>
<19> # check flow-control limits
<20> stream = self._get_or_create_stream(frame_type, stream_id)
<21> if offset + length > stream.max_stream_data_local:
<22> raise QuicConnectionError(
<23> error_code=QuicErrorCode.FLOW_CONTROL_ERROR,
<24> frame_type=frame_type,
<25> reason_phrase="Over stream data limit",
<26> )
<27> newly_received = max(0, offset + length - stream._recv_highest)
<28> if self._local_max_data_used + newly_received > self._local_max_data:
<29> raise QuicConnectionError(
<30> error_code=QuicErrorCode.FLOW_CONTROL_ERROR,
<31> frame_type=frame_type,
<32> reason_phrase="Over connection data limit",
<33> )
<34>
<35> stream.add_frame(frame)
<36> self._local_max_data_used += newly_received
<37>
|
===========unchanged ref 0===========
at: aioquic.buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic.buffer.Buffer
tell() -> int
pull_bytes(length: int) -> bytes
pull_uint_var() -> int
at: aioquic.connection
QuicConnectionError(error_code: int, frame_type: int, reason_phrase: str)
QuicReceiveContext(epoch: tls.Epoch, host_cid: bytes, network_path: QuicNetworkPath, time: float)
at: aioquic.connection.QuicConnection
_assert_stream_can_receive(frame_type: int, stream_id: int) -> None
_get_or_create_stream(frame_type: int, stream_id: int) -> QuicStream
at: aioquic.connection.QuicConnection.__init__
self._local_max_data = MAX_DATA_WINDOW
self._local_max_data_used = 0
at: aioquic.connection.QuicConnection._handle_stream_frame
stream_id = buf.pull_uint_var()
at: aioquic.connection.QuicConnection._write_connection_limits
self._local_max_data += MAX_DATA_WINDOW
at: aioquic.packet
QuicErrorCode(x: Union[str, bytes, bytearray], base: int)
QuicErrorCode(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
QuicStreamFrame(data: bytes=b"", fin: bool=False, offset: int=0)
at: aioquic.stream.QuicStream
add_frame(frame: QuicStreamFrame) -> None
at: aioquic.stream.QuicStream.__init__
self.max_stream_data_local = max_stream_data_local
self._recv_highest = 0 # the highest offset ever seen
at: aioquic.stream.QuicStream.add_frame
self._recv_highest = frame_end
===========changed ref 0===========
# module: aioquic.buffer
class Buffer:
+ def pull_bytes(self, length: int) -> bytes:
+ """
+ Pull bytes.
+ """
+ end = self._pos + length
+ if end > self._length:
+ raise BufferReadError
+ v = bytes(self._data[self._pos : end])
+ self._pos = end
+ return v
+
===========changed ref 1===========
# module: aioquic.buffer
class Buffer:
+ def pull_uint_var(self) -> int:
+ """
+ Pull a QUIC variable-length unsigned integer.
+ """
+ try:
+ kind = self._data[self._pos] // 64
+ if kind == 0:
+ value = self._data[self._pos]
+ self._pos += 1
+ return value
+ elif kind == 1:
+ value, = unpack_from("!H", self._data, self._pos)
+ self._pos += 2
+ return value & 0x3FFF
+ elif kind == 2:
+ value, = unpack_from("!L", self._data, self._pos)
+ self._pos += 4
+ return value & 0x3FFFFFFF
+ else:
+ value, = unpack_from("!Q", self._data, self._pos)
+ self._pos += 8
+ return value & 0x3FFFFFFFFFFFFFFF
+ except (IndexError, struct.error):
+ raise BufferReadError
+
===========changed ref 2===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- stream_id = pull_uint_var(buf)
+ buf.pull_uint16() # application error code
- pull_uint16(buf) # application error code
# 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.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_path_challenge_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a PATH_CHALLENGE frame.
"""
+ data = buf.pull_bytes(8)
- data = pull_bytes(buf, 8)
context.network_path.remote_challenge = data
===========changed ref 4===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_path_response_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a PATH_RESPONSE frame.
"""
+ data = buf.pull_bytes(8)
- data = pull_bytes(buf, 8)
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.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- sequence_number = pull_uint_var(buf)
# 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._connection_id_retired_handler(connection_id.cid)
break
# issue a new connection ID
self._replenish_connection_ids()
===========changed ref 6===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_data_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a DATA_BLOCKED frame.
"""
+ buf.pull_uint_var() # limit
- pull_uint_var(buf) # limit
===========changed ref 7===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- max_streams = pull_uint_var(buf)
if max_streams > self._remote_max_streams_uni:
self._logger.info("Remote max_streams_uni raised to %d", max_streams)
self._remote_max_streams_uni = max_streams
|
aioquic.connection/QuicConnection._handle_stream_data_blocked_frame
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<3>:<add> stream_id = buf.pull_uint_var()
<del> stream_id = pull_uint_var(buf)
<4>:<add> buf.pull_uint_var() # limit
<del> pull_uint_var(buf) # limit
|
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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 = pull_uint_var(buf)
<4> pull_uint_var(buf) # 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.connection
QuicReceiveContext(epoch: tls.Epoch, host_cid: bytes, network_path: QuicNetworkPath, time: float)
at: aioquic.connection.QuicConnection
_assert_stream_can_receive(frame_type: int, stream_id: int) -> None
_get_or_create_stream(frame_type: int, stream_id: int) -> QuicStream
at: aioquic.connection.QuicConnection._handle_stream_data_blocked_frame
stream_id = buf.pull_uint_var()
===========changed ref 0===========
# module: aioquic.buffer
class Buffer:
+ def pull_uint_var(self) -> int:
+ """
+ Pull a QUIC variable-length unsigned integer.
+ """
+ try:
+ kind = self._data[self._pos] // 64
+ if kind == 0:
+ value = self._data[self._pos]
+ self._pos += 1
+ return value
+ elif kind == 1:
+ value, = unpack_from("!H", self._data, self._pos)
+ self._pos += 2
+ return value & 0x3FFF
+ elif kind == 2:
+ value, = unpack_from("!L", self._data, self._pos)
+ self._pos += 4
+ return value & 0x3FFFFFFF
+ else:
+ value, = unpack_from("!Q", self._data, self._pos)
+ self._pos += 8
+ return value & 0x3FFFFFFFFFFFFFFF
+ except (IndexError, struct.error):
+ raise BufferReadError
+
===========changed ref 1===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- stream_id = pull_uint_var(buf)
+ buf.pull_uint16() # application error code
- pull_uint16(buf) # application error code
# 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.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_path_challenge_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a PATH_CHALLENGE frame.
"""
+ data = buf.pull_bytes(8)
- data = pull_bytes(buf, 8)
context.network_path.remote_challenge = data
===========changed ref 3===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_path_response_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a PATH_RESPONSE frame.
"""
+ data = buf.pull_bytes(8)
- data = pull_bytes(buf, 8)
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.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- sequence_number = pull_uint_var(buf)
# 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._connection_id_retired_handler(connection_id.cid)
break
# issue a new connection ID
self._replenish_connection_ids()
===========changed ref 5===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_data_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a DATA_BLOCKED frame.
"""
+ buf.pull_uint_var() # limit
- pull_uint_var(buf) # limit
===========changed ref 6===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- max_streams = pull_uint_var(buf)
if max_streams > self._remote_max_streams_uni:
self._logger.info("Remote max_streams_uni raised to %d", max_streams)
self._remote_max_streams_uni = max_streams
===========changed ref 7===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- stream_id = pull_uint_var(buf)
+ error_code = buf.pull_uint16()
- error_code = pull_uint16(buf)
+ final_size = buf.pull_uint_var()
- final_size = pull_uint_var(buf)
# 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)
stream.connection_lost(None)
===========changed ref 8===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- max_streams = pull_uint_var(buf)
if max_streams > self._remote_max_streams_bidi:
self._logger.info("Remote max_streams_bidi raised to %d", max_streams)
self._remote_max_streams_bidi = max_streams
|
aioquic.connection/QuicConnection._handle_streams_blocked_frame
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<3>:<add> buf.pull_uint_var() # limit
<del> pull_uint_var(buf) # limit
|
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_streams_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
<0> """
<1> Handle a STREAMS_BLOCKED frame.
<2> """
<3> pull_uint_var(buf) # limit
<4>
|
===========unchanged ref 0===========
at: aioquic.packet_builder
QuicDeliveryState()
at: aioquic.rangeset.RangeSet
subtract(start: int, stop: int) -> None
at: aioquic.recovery
QuicPacketSpace()
at: aioquic.recovery.QuicPacketSpace.__init__
self.ack_queue = RangeSet()
===========changed ref 0===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- stream_id = pull_uint_var(buf)
+ buf.pull_uint_var() # limit
- pull_uint_var(buf) # limit
# 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.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- stream_id = pull_uint_var(buf)
+ buf.pull_uint16() # application error code
- pull_uint16(buf) # application error code
# 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.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_path_challenge_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a PATH_CHALLENGE frame.
"""
+ data = buf.pull_bytes(8)
- data = pull_bytes(buf, 8)
context.network_path.remote_challenge = data
===========changed ref 3===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_path_response_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a PATH_RESPONSE frame.
"""
+ data = buf.pull_bytes(8)
- data = pull_bytes(buf, 8)
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.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- sequence_number = pull_uint_var(buf)
# 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._connection_id_retired_handler(connection_id.cid)
break
# issue a new connection ID
self._replenish_connection_ids()
===========changed ref 5===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_data_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a DATA_BLOCKED frame.
"""
+ buf.pull_uint_var() # limit
- pull_uint_var(buf) # limit
===========changed ref 6===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- max_streams = pull_uint_var(buf)
if max_streams > self._remote_max_streams_uni:
self._logger.info("Remote max_streams_uni raised to %d", max_streams)
self._remote_max_streams_uni = max_streams
===========changed ref 7===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- stream_id = pull_uint_var(buf)
+ error_code = buf.pull_uint16()
- error_code = pull_uint16(buf)
+ final_size = buf.pull_uint_var()
- final_size = pull_uint_var(buf)
# 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)
stream.connection_lost(None)
===========changed ref 8===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- max_streams = pull_uint_var(buf)
if max_streams > self._remote_max_streams_bidi:
self._logger.info("Remote max_streams_bidi raised to %d", max_streams)
self._remote_max_streams_bidi = max_streams
===========changed ref 9===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- max_data = pull_uint_var(buf)
if max_data > self._remote_max_data:
self._logger.info("Remote max_data raised to %d", max_data)
self._remote_max_data = max_data
|
aioquic.connection/QuicConnection._payload_received
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<8>:<add> frame_type = buf.pull_uint_var()
<del> frame_type = pull_uint_var(buf)
|
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _payload_received(
self, context: QuicReceiveContext, plain: bytes
) -> Tuple[bool, bool]:
<0> """
<1> Handle a QUIC packet payload.
<2> """
<3> buf = Buffer(data=plain)
<4>
<5> is_ack_eliciting = False
<6> is_probing = None
<7> while not buf.eof():
<8> frame_type = pull_uint_var(buf)
<9>
<10> # check frame type is known
<11> try:
<12> frame_handler, frame_epochs = self.__frame_handlers[frame_type]
<13> except IndexError:
<14> raise QuicConnectionError(
<15> error_code=QuicErrorCode.PROTOCOL_VIOLATION,
<16> frame_type=frame_type,
<17> reason_phrase="Unknown frame type",
<18> )
<19>
<20> # check frame is allowed for the epoch
<21> if context.epoch not in frame_epochs:
<22> raise QuicConnectionError(
<23> error_code=QuicErrorCode.PROTOCOL_VIOLATION,
<24> frame_type=frame_type,
<25> reason_phrase="Unexpected frame type",
<26> )
<27>
<28> # handle the frame
<29> if frame_type != QuicFrameType.PADDING:
<30> try:
<31> frame_handler(context, frame_type, buf)
<32> except BufferReadError:
<33> raise QuicConnectionError(
<34> error_code=QuicErrorCode.FRAME_ENCODING_ERROR,
<35> frame_type=frame_type,
<36> reason_phrase="Failed to parse frame",
<37> )
<38>
<39> # update ACK only / probing flags
<40> if frame_type not in NON_ACK_ELICITING_FRAME_TYPES:
<41> is_ack_eliciting = True
<42>
<43> if frame_type not in PROBING_FRAME_TYPES:
<44> is_probing = False
<45> elif is_probing is None:
<46> is_probing = True
<47>
<48> return is_ack_</s>
|
===========below chunk 0===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _payload_received(
self, context: QuicReceiveContext, plain: bytes
) -> Tuple[bool, bool]:
# offset: 1
===========unchanged ref 0===========
at: aioquic.buffer
BufferReadError(*args: object)
at: aioquic.buffer.Buffer
eof() -> bool
pull_uint_var() -> int
at: aioquic.connection
QuicConnectionError(error_code: int, frame_type: int, reason_phrase: str)
QuicConnectionId(cid: bytes, sequence_number: int, stateless_reset_token: bytes=b"", was_sent: bool=False)
at: aioquic.connection.QuicConnection.__init__
self._host_cids = [
QuicConnectionId(
cid=os.urandom(8),
sequence_number=0,
stateless_reset_token=os.urandom(16),
was_sent=True,
)
]
===========unchanged ref 1===========
self.__frame_handlers = [
(self._handle_padding_frame, EPOCHS("IZHO")),
(self._handle_padding_frame, EPOCHS("ZO")),
(self._handle_ack_frame, EPOCHS("IHO")),
(self._handle_ack_frame, EPOCHS("IHO")),
(self._handle_reset_stream_frame, EPOCHS("ZO")),
(self._handle_stop_sending_frame, EPOCHS("ZO")),
(self._handle_crypto_frame, EPOCHS("IHO")),
(self._handle_new_token_frame, EPOCHS("O")),
(self._handle_stream_frame, EPOCHS("ZO")),
(self._handle_stream_frame, EPOCHS("ZO")),
(self._handle_stream_frame, EPOCHS("ZO")),
(self._handle_stream_frame, EPOCHS("ZO")),
(self._handle_stream_frame, EPOCHS("ZO")),
(self._handle_stream_frame, EPOCHS("ZO")),
(self._handle_stream_frame, EPOCHS("ZO")),
(self._handle_stream_frame, EPOCHS("ZO")),
(self._handle_max_data_frame, EPOCHS("ZO")),
(self._handle_max_stream_data_frame, EPOCHS("ZO")),
(self._handle_max_streams_bidi_frame, EPOCHS("ZO")),
(self._handle_max_streams_uni_frame, EPOCHS("ZO")),
(self._handle_data_blocked_frame, EPOCHS("ZO")),
(self._handle_stream_data_blocked_frame, EPOCHS("ZO")),
(self._handle_streams_blocked_frame, EPOCHS("ZO")),
(self._handle_streams_blocked_frame, EPOCHS("ZO")),
(self._handle_new_connection_id_frame,</s>
===========unchanged ref 2===========
at: aioquic.connection.QuicConnection._payload_received
buf = Buffer(data=plain)
at: aioquic.connection.QuicReceiveContext
epoch: tls.Epoch
at: aioquic.packet
QuicErrorCode(x: Union[str, bytes, bytearray], base: int)
QuicErrorCode(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
QuicFrameType(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
QuicFrameType(x: Union[str, bytes, bytearray], base: int)
NON_ACK_ELICITING_FRAME_TYPES = frozenset(
[QuicFrameType.ACK, QuicFrameType.ACK_ECN, QuicFrameType.PADDING]
)
PROBING_FRAME_TYPES = frozenset(
[
QuicFrameType.PATH_CHALLENGE,
QuicFrameType.PATH_RESPONSE,
QuicFrameType.PADDING,
QuicFrameType.NEW_CONNECTION_ID,
]
)
at: os
urandom(size: int, /) -> bytes
===========changed ref 0===========
# module: aioquic.buffer
class Buffer:
+ def pull_uint_var(self) -> int:
+ """
+ Pull a QUIC variable-length unsigned integer.
+ """
+ try:
+ kind = self._data[self._pos] // 64
+ if kind == 0:
+ value = self._data[self._pos]
+ self._pos += 1
+ return value
+ elif kind == 1:
+ value, = unpack_from("!H", self._data, self._pos)
+ self._pos += 2
+ return value & 0x3FFF
+ elif kind == 2:
+ value, = unpack_from("!L", self._data, self._pos)
+ self._pos += 4
+ return value & 0x3FFFFFFF
+ else:
+ value, = unpack_from("!Q", self._data, self._pos)
+ self._pos += 8
+ return value & 0x3FFFFFFFFFFFFFFF
+ except (IndexError, struct.error):
+ raise BufferReadError
+
===========changed ref 1===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_streams_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a STREAMS_BLOCKED frame.
"""
+ buf.pull_uint_var() # limit
- pull_uint_var(buf) # limit
===========changed ref 2===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- stream_id = pull_uint_var(buf)
+ buf.pull_uint_var() # limit
- pull_uint_var(buf) # limit
# check stream direction
self._assert_stream_can_receive(frame_type, stream_id)
self._get_or_create_stream(frame_type, stream_id)
===========changed ref 3===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- stream_id = pull_uint_var(buf)
+ buf.pull_uint16() # application error code
- pull_uint16(buf) # application error code
# 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.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_path_challenge_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a PATH_CHALLENGE frame.
"""
+ data = buf.pull_bytes(8)
- data = pull_bytes(buf, 8)
context.network_path.remote_challenge = data
|
aioquic.connection/QuicConnection._write_application
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _write_application(
self, builder: QuicPacketBuilder, max_bytes: int, network_path: QuicNetworkPath
) -> 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 builder.flight_bytes < max_bytes or self._probe_pending:
<15> # write header
<16> builder.start_packet(packet_type, crypto)
<17>
<18> if self._handshake_complete:
<19> # ACK
<20> if space.ack_required:
<21> builder.start_frame(
<22> QuicFrameType.ACK,
<23> self._on_ack_delivery,
<24> (space, space.largest_received_packet),
<25> )
<26> push_ack_frame(buf, space.ack_queue, 0)
<27> space.ack_required = False
<28>
<29> # PATH CHALLENGE
<30> if (
<31> not network_path.is_validated
<32> and network_path.local_challenge is None
<33> ):
<34> self._logger.info(
<35> "Network path %s sending challenge", network_path.addr
<36> )
<37> network_path.local_challenge = os.urandom(8)
<38> builder.start_frame(QuicFrameType.PATH_CH</s>
|
===========below chunk 0===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _write_application(
self, builder: QuicPacketBuilder, max_bytes: int, network_path: QuicNetworkPath
) -> None:
# offset: 1
push_bytes(buf, network_path.local_challenge)
# PATH RESPONSE
if network_path.remote_challenge is not None:
builder.start_frame(QuicFrameType.PATH_RESPONSE)
push_bytes(buf, network_path.remote_challenge)
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,
connection_id.cid,
connection_id.stateless_reset_token,
)
connection_id.was_sent = True
self._connection_id_issued_handler(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,),
)
push_uint_var(buf, sequence_number)
# 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</s>
===========below chunk 1===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _write_application(
self, builder: QuicPacketBuilder, max_bytes: int, network_path: QuicNetworkPath
) -> None:
# offset: 2
<s> # PING (user-request)
if self._ping_pending:
self._logger.info("Sending PING in packet %d", builder.packet_number)
builder.start_frame(QuicFrameType.PING, self._on_ping_delivery)
self._ping_pending = False
# PING (probe)
if self._probe_pending:
self._logger.info("Sending probe")
builder.start_frame(QuicFrameType.PING)
self._probe_pending = False
# CRYPTO
if crypto_stream is not None and not crypto_stream.send_buffer_is_empty:
write_crypto_frame(builder=builder, space=space, stream=crypto_stream)
for stream in self._streams.values():
# STREAM
if not stream.send_buffer_is_empty:
self._remote_max_data_used += 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
push_bytes(v: bytes) -> None
push_uint_var(value: int) -> None
at: aioquic.connection
write_crypto_frame(builder: QuicPacketBuilder, space: QuicPacketSpace, stream: QuicStream) -> None
write_stream_frame(builder: QuicPacketBuilder, space: QuicPacketSpace, stream: QuicStream, max_offset: int) -> int
at: aioquic.connection.QuicConnection
_on_ack_delivery(delivery: QuicDeliveryState, space: QuicPacketSpace, highest_acked: int) -> None
_on_new_connection_id_delivery(delivery: QuicDeliveryState, connection_id: QuicConnectionId) -> None
_on_ping_delivery(delivery: QuicDeliveryState) -> None
_on_retire_connection_id_delivery(delivery: QuicDeliveryState, sequence_number: int) -> None
_write_connection_limits(builder: QuicPacketBuilder, space: QuicPacketSpace) -> None
_write_stream_limits(self, builder: QuicPacketBuilder, space: QuicPacketSpace, stream: QuicStream) -> None
_write_stream_limits(builder: QuicPacketBuilder, space: QuicPacketSpace, stream: QuicStream) -> None
at: aioquic.connection.QuicConnection.__init__
self._cryptos: Dict[tls.Epoch, CryptoPair] = {}
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
===========unchanged ref 1===========
self._spaces: Dict[tls.Epoch, QuicPacketSpace] = {}
self._streams: Dict[int, QuicStream] = {}
self._ping_pending = False
self._probe_pending = False
self._retire_connection_ids: List[int] = []
self._connection_id_issued_handler: QuicConnectionIdHandler = lambda c: None
at: aioquic.connection.QuicConnection._handle_crypto_frame
self._handshake_complete = True
at: aioquic.connection.QuicConnection._handle_max_data_frame
self._remote_max_data = max_data
at: aioquic.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.connection.QuicConnection._on_ping_delivery
self._ping_pending = True
at: aioquic.connection.QuicConnection._send_probe
self._probe_pending = True
at: aioquic.connection.QuicConnection._write_application
crypto_stream: Optional[QuicStream] = None
crypto_stream = self._crypto_streams[tls.Epoch.ONE_RTT]
at: aioquic.connection.QuicConnection.ping
self._ping_pending = True
at: aioquic.connection.QuicConnectionId
cid: bytes
sequence_number: int
stateless_reset_token: bytes = b""
was_sent: bool = False
at: aioquic.connection.QuicNetworkPath
addr: NetworkAddress
is_validated: bool = False
|
|
aioquic.connection/QuicConnection._write_connection_limits
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<6>:<add> builder.buffer.push_uint_var(self._local_max_data)
<del> push_uint_var(builder.buffer, self._local_max_data)
|
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _write_connection_limits(
self, builder: QuicPacketBuilder, space: QuicPacketSpace
) -> None:
<0> # raise MAX_DATA if needed
<1> if self._local_max_data_used + MAX_DATA_WINDOW // 2 > self._local_max_data:
<2> self._local_max_data += MAX_DATA_WINDOW
<3> self._logger.info("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> push_uint_var(builder.buffer, self._local_max_data)
<7> self._local_max_data_sent = self._local_max_data
<8>
|
===========unchanged ref 0===========
at: aioquic.buffer.Buffer
push_uint_var(value: int) -> None
at: aioquic.connection
MAX_DATA_WINDOW = 1048576
at: aioquic.connection.QuicConnection.__init__
self._local_max_data = MAX_DATA_WINDOW
self._local_max_data_sent = MAX_DATA_WINDOW
self._logger = QuicConnectionAdapter(
logger, {"host_cid": dump_cid(self.host_cid)}
)
at: aioquic.connection.QuicConnection._on_max_data_delivery
self._local_max_data_sent = 0
at: aioquic.connection.QuicConnection._write_connection_limits
self._local_max_data += MAX_DATA_WINDOW
at: aioquic.packet_builder
QuicPacketBuilder(*, host_cid: bytes, peer_cid: bytes, version: int, pad_first_datagram: bool=False, packet_number: int=0, peer_token: bytes=b"", spin_bit: bool=False)
at: aioquic.packet_builder.QuicPacketBuilder.__init__
self.buffer = Buffer(PACKET_MAX_SIZE)
at: aioquic.recovery
QuicPacketSpace()
at: aioquic.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.stream.QuicStream.__init__
self.max_stream_data_local = max_stream_data_local
self._recv_highest = 0 # the highest offset ever seen
at: aioquic.stream.QuicStream.add_frame
self._recv_highest = frame_end
===========unchanged ref 1===========
at: logging.LoggerAdapter
info(msg: Any, *args: Any, exc_info: _ExcInfoType=..., stack_info: bool=..., extra: Optional[Dict[str, Any]]=..., **kwargs: Any) -> None
===========changed ref 0===========
# module: aioquic.buffer
class Buffer:
+ def push_uint_var(self, value: int) -> None:
+ """
+ Push a QUIC variable-length unsigned integer.
+ """
+ if value <= 0x3F:
+ self._data[self._pos] = value
+ self._pos += 1
+ elif value <= 0x3FFF:
+ pack_into("!H", self._data, self._pos, value | 0x4000)
+ self._pos += 2
+ elif value <= 0x3FFFFFFF:
+ pack_into("!L", self._data, self._pos, value | 0x80000000)
+ self._pos += 4
+ elif value <= 0x3FFFFFFFFFFFFFFF:
+ pack_into("!Q", self._data, self._pos, value | 0xC000000000000000)
+ self._pos += 8
+ else:
+ raise ValueError("Integer is too big for a variable-length integer")
+
===========changed ref 1===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_streams_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a STREAMS_BLOCKED frame.
"""
+ buf.pull_uint_var() # limit
- pull_uint_var(buf) # limit
===========changed ref 2===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- stream_id = pull_uint_var(buf)
+ buf.pull_uint_var() # limit
- pull_uint_var(buf) # limit
# check stream direction
self._assert_stream_can_receive(frame_type, stream_id)
self._get_or_create_stream(frame_type, stream_id)
===========changed ref 3===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- stream_id = pull_uint_var(buf)
+ buf.pull_uint16() # application error code
- pull_uint16(buf) # application error code
# 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.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_path_challenge_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a PATH_CHALLENGE frame.
"""
+ data = buf.pull_bytes(8)
- data = pull_bytes(buf, 8)
context.network_path.remote_challenge = data
===========changed ref 5===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_path_response_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a PATH_RESPONSE frame.
"""
+ data = buf.pull_bytes(8)
- data = pull_bytes(buf, 8)
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.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- sequence_number = pull_uint_var(buf)
# 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._connection_id_retired_handler(connection_id.cid)
break
# issue a new connection ID
self._replenish_connection_ids()
===========changed ref 7===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_data_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a DATA_BLOCKED frame.
"""
+ buf.pull_uint_var() # limit
- pull_uint_var(buf) # limit
|
aioquic.connection/QuicConnection._write_stream_limits
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<14>:<add> builder.buffer.push_uint_var(stream.stream_id)
<del> push_uint_var(builder.buffer, stream.stream_id)
<15>:<add> builder.buffer.push_uint_var(stream.max_stream_data_local)
<del> push_uint_var(builder.buffer, stream.max_stream_data_local)
|
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _write_stream_limits(
self, builder: QuicPacketBuilder, space: QuicPacketSpace, stream: QuicStream
) -> None:
<0> # raise MAX_STREAM_DATA if needed
<1> if stream._recv_highest + MAX_DATA_WINDOW // 2 > stream.max_stream_data_local:
<2> stream.max_stream_data_local += MAX_DATA_WINDOW
<3> self._logger.info(
<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> push_uint_var(builder.buffer, stream.stream_id)
<15> push_uint_var(builder.buffer, stream.max_stream_data_local)
<16> stream.max_stream_data_local_sent = stream.max_stream_data_local
<17>
|
===========unchanged ref 0===========
at: aioquic.buffer.Buffer
push_uint_var(value: int) -> None
at: aioquic.connection.QuicConnection
_on_max_stream_data_delivery(delivery: QuicDeliveryState, stream: QuicStream) -> None
at: aioquic.packet
QuicFrameType(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
QuicFrameType(x: Union[str, bytes, bytearray], base: int)
at: aioquic.packet_builder.QuicPacketBuilder
start_frame(frame_type: int, handler: Optional[QuicDeliveryHandler]=None, args: Sequence[Any]=[]) -> None
at: aioquic.packet_builder.QuicPacketBuilder.__init__
self.buffer = Buffer(PACKET_MAX_SIZE)
at: aioquic.stream.QuicStream.__init__
self.max_stream_data_local = max_stream_data_local
self.max_stream_data_local_sent = max_stream_data_local
===========changed ref 0===========
# module: aioquic.packet_builder
class QuicPacketBuilder:
def start_frame(
self,
frame_type: int,
handler: Optional[QuicDeliveryHandler] = None,
args: Sequence[Any] = [],
) -> None:
"""
Starts a new frame.
"""
+ self.buffer.push_uint_var(frame_type)
- push_uint_var(self.buffer, frame_type)
if frame_type not in NON_ACK_ELICITING_FRAME_TYPES:
# FIXME: in_flight != is_ack_eliciting
self._packet.in_flight = True
self._packet.is_ack_eliciting = True
self._ack_eliciting = True
if frame_type == QuicFrameType.CRYPTO:
self._packet.is_crypto_packet = True
if handler is not None:
self._packet.delivery_handlers.append((handler, args))
===========changed ref 1===========
# module: aioquic.buffer
class Buffer:
+ def push_uint_var(self, value: int) -> None:
+ """
+ Push a QUIC variable-length unsigned integer.
+ """
+ if value <= 0x3F:
+ self._data[self._pos] = value
+ self._pos += 1
+ elif value <= 0x3FFF:
+ pack_into("!H", self._data, self._pos, value | 0x4000)
+ self._pos += 2
+ elif value <= 0x3FFFFFFF:
+ pack_into("!L", self._data, self._pos, value | 0x80000000)
+ self._pos += 4
+ elif value <= 0x3FFFFFFFFFFFFFFF:
+ pack_into("!Q", self._data, self._pos, value | 0xC000000000000000)
+ self._pos += 8
+ else:
+ raise ValueError("Integer is too big for a variable-length integer")
+
===========changed ref 2===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _write_connection_limits(
self, builder: QuicPacketBuilder, space: QuicPacketSpace
) -> None:
# raise MAX_DATA if needed
if self._local_max_data_used + MAX_DATA_WINDOW // 2 > self._local_max_data:
self._local_max_data += MAX_DATA_WINDOW
self._logger.info("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)
- push_uint_var(builder.buffer, self._local_max_data)
self._local_max_data_sent = self._local_max_data
===========changed ref 3===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_streams_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a STREAMS_BLOCKED frame.
"""
+ buf.pull_uint_var() # limit
- pull_uint_var(buf) # limit
===========changed ref 4===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- stream_id = pull_uint_var(buf)
+ buf.pull_uint_var() # limit
- pull_uint_var(buf) # limit
# check stream direction
self._assert_stream_can_receive(frame_type, stream_id)
self._get_or_create_stream(frame_type, stream_id)
===========changed ref 5===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
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()
- stream_id = pull_uint_var(buf)
+ buf.pull_uint16() # application error code
- pull_uint16(buf) # application error code
# check stream direction
self._assert_stream_can_send(frame_type, stream_id)
self._get_or_create_stream(frame_type, stream_id)
===========changed ref 6===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_path_challenge_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a PATH_CHALLENGE frame.
"""
+ data = buf.pull_bytes(8)
- data = pull_bytes(buf, 8)
context.network_path.remote_challenge = data
===========changed ref 7===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_path_response_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a PATH_RESPONSE frame.
"""
+ data = buf.pull_bytes(8)
- data = pull_bytes(buf, 8)
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
|
tests.test_buffer/BufferTest.test_pull_bytes
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<1>:<add> self.assertEqual(buf.pull_bytes(3), b"\x08\x07\x06")
<del> self.assertEqual(pull_bytes(buf, 3), b"\x08\x07\x06")
|
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_bytes(self):
<0> buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
<1> self.assertEqual(pull_bytes(buf, 3), b"\x08\x07\x06")
<2>
|
===========unchanged ref 0===========
at: aioquic.buffer.Buffer
tell() -> int
at: tests.test_buffer.BufferTest.test_pull_uint8
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
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_buffer
class BufferTest(TestCase):
+ def test_data_slice(self):
+ buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.data_slice(1, 3), b"\x07\x06")
+
===========changed ref 1===========
# module: aioquic.tls
def pull_group(buf: Buffer) -> Group:
+ return Group(buf.pull_uint16())
- return Group(pull_uint16(buf))
===========changed ref 2===========
# module: aioquic.tls
def pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm:
+ return SignatureAlgorithm(buf.pull_uint16())
- return SignatureAlgorithm(pull_uint16(buf))
===========changed ref 3===========
# module: aioquic.tls
def pull_compression_method(buf: Buffer) -> CompressionMethod:
+ return CompressionMethod(buf.pull_uint8())
- return CompressionMethod(pull_uint8(buf))
===========changed ref 4===========
# module: aioquic.tls
# INTEGERS
def pull_cipher_suite(buf: Buffer) -> CipherSuite:
+ return CipherSuite(buf.pull_uint16())
- return CipherSuite(pull_uint16(buf))
===========changed ref 5===========
# module: aioquic.tls
def pull_key_exchange_mode(buf: Buffer) -> KeyExchangeMode:
+ return KeyExchangeMode(buf.pull_uint8())
- return KeyExchangeMode(pull_uint8(buf))
===========changed ref 6===========
# module: aioquic.buffer
class Buffer:
+ def push_uint8(self, v: int) -> None:
+ """
+ Push an 8-bit unsigned integer.
+ """
+ self._data[self._pos] = v
+ self._pos += 1
+
===========changed ref 7===========
# module: aioquic.tls
def push_key_share(buf: Buffer, value: KeyShareEntry) -> None:
+ buf.push_uint16(value[0])
- push_group(buf, value[0])
push_opaque(buf, 2, value[1])
===========changed ref 8===========
# module: aioquic.tls
@contextmanager
def push_extension(buf: Buffer, extension_type: int) -> Generator:
+ buf.push_uint16(extension_type)
- push_uint16(buf, extension_type)
with push_block(buf, 2):
yield
===========changed ref 9===========
# module: aioquic.buffer
- def push_uint8(buf: Buffer, v: int) -> None:
- """
- Push an 8-bit unsigned integer.
- """
- buf._data[buf._pos] = v
- buf._pos += 1
-
===========changed ref 10===========
# module: aioquic.tls
def push_psk_identity(buf: Buffer, entry: PskIdentity) -> None:
push_opaque(buf, 2, entry[0])
+ buf.push_uint32(entry[1])
- push_uint32(buf, entry[1])
===========changed ref 11===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_data_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a DATA_BLOCKED frame.
"""
+ buf.pull_uint_var() # limit
- pull_uint_var(buf) # limit
===========changed ref 12===========
# module: aioquic.buffer
class Buffer:
+ def push_uint64(self, v: int) -> None:
+ """
+ Push a 64-bit unsigned integer.
+ """
+ pack_into("!Q", self._data, self._pos, v)
+ self._pos += 8
+
===========changed ref 13===========
# module: aioquic.buffer
class Buffer:
+ def push_uint32(self, v: int) -> None:
+ """
+ Push a 32-bit unsigned integer.
+ """
+ pack_into("!L", self._data, self._pos, v)
+ self._pos += 4
+
===========changed ref 14===========
# module: aioquic.buffer
class Buffer:
+ def push_uint16(self, v: int) -> None:
+ """
+ Push a 16-bit unsigned integer.
+ """
+ pack_into("!H", self._data, self._pos, v)
+ self._pos += 2
+
===========changed ref 15===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_streams_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a STREAMS_BLOCKED frame.
"""
+ buf.pull_uint_var() # limit
- pull_uint_var(buf) # limit
===========changed ref 16===========
# module: aioquic.tls
def push_list(
+ buf: Buffer, capacity: int, func: Callable[[T], None], values: Sequence[T]
- buf: Buffer, capacity: int, func: Callable[[Buffer, T], None], values: Sequence[T]
) -> None:
"""
Push a list of items.
"""
with push_block(buf, capacity):
for value in values:
+ func(value)
- func(buf, value)
===========changed ref 17===========
# module: aioquic.packet
def pull_new_token_frame(buf: Buffer) -> bytes:
+ length = buf.pull_uint_var()
- length = pull_uint_var(buf)
+ return buf.pull_bytes(length)
- return pull_bytes(buf, length)
===========changed ref 18===========
# module: aioquic.tls
def push_finished(buf: Buffer, finished: Finished) -> None:
+ buf.push_uint8(HandshakeType.FINISHED)
- push_uint8(buf, HandshakeType.FINISHED)
push_opaque(buf, 3, finished.verify_data)
===========changed ref 19===========
# module: aioquic.buffer
- def push_uint64(buf: Buffer, v: int) -> None:
- """
- Push a 64-bit unsigned integer.
- """
- pack_into("!Q", buf._data, buf._pos, v)
- buf._pos += 8
-
===========changed ref 20===========
# module: aioquic.buffer
- def push_uint32(buf: Buffer, v: int) -> None:
- """
- Push a 32-bit unsigned integer.
- """
- pack_into("!L", buf._data, buf._pos, v)
- buf._pos += 4
-
===========changed ref 21===========
# module: aioquic.buffer
- def push_uint16(buf: Buffer, v: int) -> None:
- """
- Push a 16-bit unsigned integer.
- """
- pack_into("!H", buf._data, buf._pos, v)
- buf._pos += 2
-
===========changed ref 22===========
# module: aioquic.tls
def push_opaque(buf: Buffer, capacity: int, value: bytes) -> None:
"""
Push an opaque value prefix by a length.
"""
with push_block(buf, capacity):
+ buf.push_bytes(value)
- push_bytes(buf, value)
===========changed ref 23===========
# module: aioquic.packet
def push_new_token_frame(buf: Buffer, token: bytes) -> None:
+ buf.push_uint_var(len(token))
- push_uint_var(buf, len(token))
+ buf.push_bytes(token)
- push_bytes(buf, token)
|
tests.test_buffer/BufferTest.test_pull_bytes_truncated
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<2>:<add> buf.pull_bytes(2)
<del> pull_bytes(buf, 2)
|
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_bytes_truncated(self):
<0> buf = Buffer(capacity=0)
<1> with self.assertRaises(BufferReadError):
<2> pull_bytes(buf, 2)
<3> self.assertEqual(buf.tell(), 0)
<4>
|
===========unchanged ref 0===========
at: aioquic.buffer
BufferReadError(*args: object)
at: aioquic.buffer.Buffer
tell() -> int
pull_uint8() -> int
at: tests.test_buffer.BufferTest.test_pull_uint8_truncated
buf = Buffer(capacity=0)
at: unittest.case.TestCase
assertEqual(first: Any, second: Any, msg: Any=...) -> None
assertRaises(expected_exception: Union[Type[_E], Tuple[Type[_E], ...]], msg: Any=...) -> _AssertRaisesContext[_E]
assertRaises(expected_exception: Union[Type[BaseException], Tuple[Type[BaseException], ...]], callable: Callable[..., Any], *args: Any, **kwargs: Any) -> None
===========changed ref 0===========
# module: aioquic.buffer
class Buffer:
+ def pull_uint8(self) -> int:
+ """
+ Pull an 8-bit unsigned integer.
+ """
+ try:
+ v = self._data[self._pos]
+ self._pos += 1
+ return v
+ except IndexError:
+ raise BufferReadError
+
===========changed ref 1===========
# module: tests.test_buffer
class BufferTest(TestCase):
+ def test_data_slice(self):
+ buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.data_slice(1, 3), b"\x07\x06")
+
===========changed ref 2===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_bytes(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_bytes(3), b"\x08\x07\x06")
- self.assertEqual(pull_bytes(buf, 3), b"\x08\x07\x06")
===========changed ref 3===========
# module: aioquic.tls
def pull_group(buf: Buffer) -> Group:
+ return Group(buf.pull_uint16())
- return Group(pull_uint16(buf))
===========changed ref 4===========
# module: aioquic.tls
def pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm:
+ return SignatureAlgorithm(buf.pull_uint16())
- return SignatureAlgorithm(pull_uint16(buf))
===========changed ref 5===========
# module: aioquic.tls
def pull_compression_method(buf: Buffer) -> CompressionMethod:
+ return CompressionMethod(buf.pull_uint8())
- return CompressionMethod(pull_uint8(buf))
===========changed ref 6===========
# module: aioquic.tls
# INTEGERS
def pull_cipher_suite(buf: Buffer) -> CipherSuite:
+ return CipherSuite(buf.pull_uint16())
- return CipherSuite(pull_uint16(buf))
===========changed ref 7===========
# module: aioquic.tls
def pull_key_exchange_mode(buf: Buffer) -> KeyExchangeMode:
+ return KeyExchangeMode(buf.pull_uint8())
- return KeyExchangeMode(pull_uint8(buf))
===========changed ref 8===========
# module: aioquic.buffer
class Buffer:
+ def push_uint8(self, v: int) -> None:
+ """
+ Push an 8-bit unsigned integer.
+ """
+ self._data[self._pos] = v
+ self._pos += 1
+
===========changed ref 9===========
# module: aioquic.tls
def push_key_share(buf: Buffer, value: KeyShareEntry) -> None:
+ buf.push_uint16(value[0])
- push_group(buf, value[0])
push_opaque(buf, 2, value[1])
===========changed ref 10===========
# module: aioquic.tls
@contextmanager
def push_extension(buf: Buffer, extension_type: int) -> Generator:
+ buf.push_uint16(extension_type)
- push_uint16(buf, extension_type)
with push_block(buf, 2):
yield
===========changed ref 11===========
# module: aioquic.buffer
- def push_uint8(buf: Buffer, v: int) -> None:
- """
- Push an 8-bit unsigned integer.
- """
- buf._data[buf._pos] = v
- buf._pos += 1
-
===========changed ref 12===========
# module: aioquic.tls
def push_psk_identity(buf: Buffer, entry: PskIdentity) -> None:
push_opaque(buf, 2, entry[0])
+ buf.push_uint32(entry[1])
- push_uint32(buf, entry[1])
===========changed ref 13===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_data_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a DATA_BLOCKED frame.
"""
+ buf.pull_uint_var() # limit
- pull_uint_var(buf) # limit
===========changed ref 14===========
# module: aioquic.buffer
class Buffer:
+ def push_uint64(self, v: int) -> None:
+ """
+ Push a 64-bit unsigned integer.
+ """
+ pack_into("!Q", self._data, self._pos, v)
+ self._pos += 8
+
===========changed ref 15===========
# module: aioquic.buffer
class Buffer:
+ def push_uint32(self, v: int) -> None:
+ """
+ Push a 32-bit unsigned integer.
+ """
+ pack_into("!L", self._data, self._pos, v)
+ self._pos += 4
+
===========changed ref 16===========
# module: aioquic.buffer
class Buffer:
+ def push_uint16(self, v: int) -> None:
+ """
+ Push a 16-bit unsigned integer.
+ """
+ pack_into("!H", self._data, self._pos, v)
+ self._pos += 2
+
===========changed ref 17===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_streams_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a STREAMS_BLOCKED frame.
"""
+ buf.pull_uint_var() # limit
- pull_uint_var(buf) # limit
===========changed ref 18===========
# module: aioquic.tls
def push_list(
+ buf: Buffer, capacity: int, func: Callable[[T], None], values: Sequence[T]
- buf: Buffer, capacity: int, func: Callable[[Buffer, T], None], values: Sequence[T]
) -> None:
"""
Push a list of items.
"""
with push_block(buf, capacity):
for value in values:
+ func(value)
- func(buf, value)
===========changed ref 19===========
# module: aioquic.packet
def pull_new_token_frame(buf: Buffer) -> bytes:
+ length = buf.pull_uint_var()
- length = pull_uint_var(buf)
+ return buf.pull_bytes(length)
- return pull_bytes(buf, length)
===========changed ref 20===========
# module: aioquic.tls
def push_finished(buf: Buffer, finished: Finished) -> None:
+ buf.push_uint8(HandshakeType.FINISHED)
- push_uint8(buf, HandshakeType.FINISHED)
push_opaque(buf, 3, finished.verify_data)
===========changed ref 21===========
# module: aioquic.buffer
- def push_uint64(buf: Buffer, v: int) -> None:
- """
- Push a 64-bit unsigned integer.
- """
- pack_into("!Q", buf._data, buf._pos, v)
- buf._pos += 8
-
===========changed ref 22===========
# module: aioquic.buffer
- def push_uint32(buf: Buffer, v: int) -> None:
- """
- Push a 32-bit unsigned integer.
- """
- pack_into("!L", buf._data, buf._pos, v)
- buf._pos += 4
-
|
tests.test_buffer/BufferTest.test_pull_uint8
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<1>:<add> self.assertEqual(buf.pull_uint8(), 0x08)
<del> self.assertEqual(pull_uint8(buf), 0x08)
|
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint8(self):
<0> buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
<1> self.assertEqual(pull_uint8(buf), 0x08)
<2> self.assertEqual(buf.tell(), 1)
<3>
|
===========unchanged ref 0===========
at: aioquic.buffer.Buffer
tell() -> int
pull_uint16() -> int
at: tests.test_buffer.BufferTest.test_pull_uint16
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
at: unittest.case.TestCase
assertEqual(first: Any, second: Any, msg: Any=...) -> None
===========changed ref 0===========
# module: aioquic.buffer
class Buffer:
+ def pull_uint16(self) -> int:
+ """
+ Pull a 16-bit unsigned integer.
+ """
+ try:
+ v, = struct.unpack_from("!H", self._data, self._pos)
+ self._pos += 2
+ return v
+ except struct.error:
+ raise BufferReadError
+
===========changed ref 1===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_bytes_truncated(self):
buf = Buffer(capacity=0)
with self.assertRaises(BufferReadError):
+ buf.pull_bytes(2)
- pull_bytes(buf, 2)
self.assertEqual(buf.tell(), 0)
===========changed ref 2===========
# module: tests.test_buffer
class BufferTest(TestCase):
+ def test_data_slice(self):
+ buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.data_slice(1, 3), b"\x07\x06")
+
===========changed ref 3===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_bytes(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_bytes(3), b"\x08\x07\x06")
- self.assertEqual(pull_bytes(buf, 3), b"\x08\x07\x06")
===========changed ref 4===========
# module: aioquic.tls
def pull_group(buf: Buffer) -> Group:
+ return Group(buf.pull_uint16())
- return Group(pull_uint16(buf))
===========changed ref 5===========
# module: aioquic.tls
def pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm:
+ return SignatureAlgorithm(buf.pull_uint16())
- return SignatureAlgorithm(pull_uint16(buf))
===========changed ref 6===========
# module: aioquic.tls
def pull_compression_method(buf: Buffer) -> CompressionMethod:
+ return CompressionMethod(buf.pull_uint8())
- return CompressionMethod(pull_uint8(buf))
===========changed ref 7===========
# module: aioquic.tls
# INTEGERS
def pull_cipher_suite(buf: Buffer) -> CipherSuite:
+ return CipherSuite(buf.pull_uint16())
- return CipherSuite(pull_uint16(buf))
===========changed ref 8===========
# module: aioquic.tls
def pull_key_exchange_mode(buf: Buffer) -> KeyExchangeMode:
+ return KeyExchangeMode(buf.pull_uint8())
- return KeyExchangeMode(pull_uint8(buf))
===========changed ref 9===========
# module: aioquic.buffer
class Buffer:
+ def push_uint8(self, v: int) -> None:
+ """
+ Push an 8-bit unsigned integer.
+ """
+ self._data[self._pos] = v
+ self._pos += 1
+
===========changed ref 10===========
# module: aioquic.tls
def push_key_share(buf: Buffer, value: KeyShareEntry) -> None:
+ buf.push_uint16(value[0])
- push_group(buf, value[0])
push_opaque(buf, 2, value[1])
===========changed ref 11===========
# module: aioquic.tls
@contextmanager
def push_extension(buf: Buffer, extension_type: int) -> Generator:
+ buf.push_uint16(extension_type)
- push_uint16(buf, extension_type)
with push_block(buf, 2):
yield
===========changed ref 12===========
# module: aioquic.buffer
- def push_uint8(buf: Buffer, v: int) -> None:
- """
- Push an 8-bit unsigned integer.
- """
- buf._data[buf._pos] = v
- buf._pos += 1
-
===========changed ref 13===========
# module: aioquic.tls
def push_psk_identity(buf: Buffer, entry: PskIdentity) -> None:
push_opaque(buf, 2, entry[0])
+ buf.push_uint32(entry[1])
- push_uint32(buf, entry[1])
===========changed ref 14===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_data_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a DATA_BLOCKED frame.
"""
+ buf.pull_uint_var() # limit
- pull_uint_var(buf) # limit
===========changed ref 15===========
# module: aioquic.buffer
class Buffer:
+ def push_uint64(self, v: int) -> None:
+ """
+ Push a 64-bit unsigned integer.
+ """
+ pack_into("!Q", self._data, self._pos, v)
+ self._pos += 8
+
===========changed ref 16===========
# module: aioquic.buffer
class Buffer:
+ def push_uint32(self, v: int) -> None:
+ """
+ Push a 32-bit unsigned integer.
+ """
+ pack_into("!L", self._data, self._pos, v)
+ self._pos += 4
+
===========changed ref 17===========
# module: aioquic.buffer
class Buffer:
+ def push_uint16(self, v: int) -> None:
+ """
+ Push a 16-bit unsigned integer.
+ """
+ pack_into("!H", self._data, self._pos, v)
+ self._pos += 2
+
===========changed ref 18===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_streams_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a STREAMS_BLOCKED frame.
"""
+ buf.pull_uint_var() # limit
- pull_uint_var(buf) # limit
===========changed ref 19===========
# module: aioquic.tls
def push_list(
+ buf: Buffer, capacity: int, func: Callable[[T], None], values: Sequence[T]
- buf: Buffer, capacity: int, func: Callable[[Buffer, T], None], values: Sequence[T]
) -> None:
"""
Push a list of items.
"""
with push_block(buf, capacity):
for value in values:
+ func(value)
- func(buf, value)
===========changed ref 20===========
# module: aioquic.packet
def pull_new_token_frame(buf: Buffer) -> bytes:
+ length = buf.pull_uint_var()
- length = pull_uint_var(buf)
+ return buf.pull_bytes(length)
- return pull_bytes(buf, length)
===========changed ref 21===========
# module: aioquic.tls
def push_finished(buf: Buffer, finished: Finished) -> None:
+ buf.push_uint8(HandshakeType.FINISHED)
- push_uint8(buf, HandshakeType.FINISHED)
push_opaque(buf, 3, finished.verify_data)
===========changed ref 22===========
# module: aioquic.buffer
- def push_uint64(buf: Buffer, v: int) -> None:
- """
- Push a 64-bit unsigned integer.
- """
- pack_into("!Q", buf._data, buf._pos, v)
- buf._pos += 8
-
|
tests.test_buffer/BufferTest.test_pull_uint8_truncated
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<2>:<add> buf.pull_uint8()
<del> pull_uint8(buf)
|
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint8_truncated(self):
<0> buf = Buffer(capacity=0)
<1> with self.assertRaises(BufferReadError):
<2> pull_uint8(buf)
<3> self.assertEqual(buf.tell(), 0)
<4>
|
===========unchanged ref 0===========
at: aioquic.buffer
BufferReadError(*args: object)
at: aioquic.buffer.Buffer
tell() -> int
pull_uint16() -> int
at: tests.test_buffer.BufferTest.test_pull_uint16_truncated
buf = Buffer(capacity=1)
at: unittest.case.TestCase
assertEqual(first: Any, second: Any, msg: Any=...) -> None
assertRaises(expected_exception: Union[Type[_E], Tuple[Type[_E], ...]], msg: Any=...) -> _AssertRaisesContext[_E]
assertRaises(expected_exception: Union[Type[BaseException], Tuple[Type[BaseException], ...]], callable: Callable[..., Any], *args: Any, **kwargs: Any) -> None
===========changed ref 0===========
# module: aioquic.buffer
class Buffer:
+ def pull_uint16(self) -> int:
+ """
+ Pull a 16-bit unsigned integer.
+ """
+ try:
+ v, = struct.unpack_from("!H", self._data, self._pos)
+ self._pos += 2
+ return v
+ except struct.error:
+ raise BufferReadError
+
===========changed ref 1===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_bytes_truncated(self):
buf = Buffer(capacity=0)
with self.assertRaises(BufferReadError):
+ buf.pull_bytes(2)
- pull_bytes(buf, 2)
self.assertEqual(buf.tell(), 0)
===========changed ref 2===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint8(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint8(), 0x08)
- self.assertEqual(pull_uint8(buf), 0x08)
self.assertEqual(buf.tell(), 1)
===========changed ref 3===========
# module: tests.test_buffer
class BufferTest(TestCase):
+ def test_data_slice(self):
+ buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.data_slice(1, 3), b"\x07\x06")
+
===========changed ref 4===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_bytes(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_bytes(3), b"\x08\x07\x06")
- self.assertEqual(pull_bytes(buf, 3), b"\x08\x07\x06")
===========changed ref 5===========
# module: aioquic.tls
def pull_group(buf: Buffer) -> Group:
+ return Group(buf.pull_uint16())
- return Group(pull_uint16(buf))
===========changed ref 6===========
# module: aioquic.tls
def pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm:
+ return SignatureAlgorithm(buf.pull_uint16())
- return SignatureAlgorithm(pull_uint16(buf))
===========changed ref 7===========
# module: aioquic.tls
def pull_compression_method(buf: Buffer) -> CompressionMethod:
+ return CompressionMethod(buf.pull_uint8())
- return CompressionMethod(pull_uint8(buf))
===========changed ref 8===========
# module: aioquic.tls
# INTEGERS
def pull_cipher_suite(buf: Buffer) -> CipherSuite:
+ return CipherSuite(buf.pull_uint16())
- return CipherSuite(pull_uint16(buf))
===========changed ref 9===========
# module: aioquic.tls
def pull_key_exchange_mode(buf: Buffer) -> KeyExchangeMode:
+ return KeyExchangeMode(buf.pull_uint8())
- return KeyExchangeMode(pull_uint8(buf))
===========changed ref 10===========
# module: aioquic.buffer
class Buffer:
+ def push_uint8(self, v: int) -> None:
+ """
+ Push an 8-bit unsigned integer.
+ """
+ self._data[self._pos] = v
+ self._pos += 1
+
===========changed ref 11===========
# module: aioquic.tls
def push_key_share(buf: Buffer, value: KeyShareEntry) -> None:
+ buf.push_uint16(value[0])
- push_group(buf, value[0])
push_opaque(buf, 2, value[1])
===========changed ref 12===========
# module: aioquic.tls
@contextmanager
def push_extension(buf: Buffer, extension_type: int) -> Generator:
+ buf.push_uint16(extension_type)
- push_uint16(buf, extension_type)
with push_block(buf, 2):
yield
===========changed ref 13===========
# module: aioquic.buffer
- def push_uint8(buf: Buffer, v: int) -> None:
- """
- Push an 8-bit unsigned integer.
- """
- buf._data[buf._pos] = v
- buf._pos += 1
-
===========changed ref 14===========
# module: aioquic.tls
def push_psk_identity(buf: Buffer, entry: PskIdentity) -> None:
push_opaque(buf, 2, entry[0])
+ buf.push_uint32(entry[1])
- push_uint32(buf, entry[1])
===========changed ref 15===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_data_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a DATA_BLOCKED frame.
"""
+ buf.pull_uint_var() # limit
- pull_uint_var(buf) # limit
===========changed ref 16===========
# module: aioquic.buffer
class Buffer:
+ def push_uint64(self, v: int) -> None:
+ """
+ Push a 64-bit unsigned integer.
+ """
+ pack_into("!Q", self._data, self._pos, v)
+ self._pos += 8
+
===========changed ref 17===========
# module: aioquic.buffer
class Buffer:
+ def push_uint32(self, v: int) -> None:
+ """
+ Push a 32-bit unsigned integer.
+ """
+ pack_into("!L", self._data, self._pos, v)
+ self._pos += 4
+
===========changed ref 18===========
# module: aioquic.buffer
class Buffer:
+ def push_uint16(self, v: int) -> None:
+ """
+ Push a 16-bit unsigned integer.
+ """
+ pack_into("!H", self._data, self._pos, v)
+ self._pos += 2
+
===========changed ref 19===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_streams_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a STREAMS_BLOCKED frame.
"""
+ buf.pull_uint_var() # limit
- pull_uint_var(buf) # limit
===========changed ref 20===========
# module: aioquic.tls
def push_list(
+ buf: Buffer, capacity: int, func: Callable[[T], None], values: Sequence[T]
- buf: Buffer, capacity: int, func: Callable[[Buffer, T], None], values: Sequence[T]
) -> None:
"""
Push a list of items.
"""
with push_block(buf, capacity):
for value in values:
+ func(value)
- func(buf, value)
===========changed ref 21===========
# module: aioquic.packet
def pull_new_token_frame(buf: Buffer) -> bytes:
+ length = buf.pull_uint_var()
- length = pull_uint_var(buf)
+ return buf.pull_bytes(length)
- return pull_bytes(buf, length)
|
tests.test_buffer/BufferTest.test_pull_uint16
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<1>:<add> self.assertEqual(buf.pull_uint16(), 0x0807)
<del> self.assertEqual(pull_uint16(buf), 0x0807)
|
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint16(self):
<0> buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
<1> self.assertEqual(pull_uint16(buf), 0x0807)
<2> self.assertEqual(buf.tell(), 2)
<3>
|
===========unchanged ref 0===========
at: aioquic.buffer.Buffer
tell() -> int
pull_uint32() -> int
at: tests.test_buffer.BufferTest.test_pull_uint32
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
at: unittest.case.TestCase
assertEqual(first: Any, second: Any, msg: Any=...) -> None
===========changed ref 0===========
# module: aioquic.buffer
class Buffer:
+ def pull_uint32(self) -> int:
+ """
+ Pull a 32-bit unsigned integer.
+ """
+ try:
+ v, = struct.unpack_from("!L", self._data, self._pos)
+ self._pos += 4
+ return v
+ except struct.error:
+ raise BufferReadError
+
===========changed ref 1===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint8_truncated(self):
buf = Buffer(capacity=0)
with self.assertRaises(BufferReadError):
+ buf.pull_uint8()
- pull_uint8(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 2===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_bytes_truncated(self):
buf = Buffer(capacity=0)
with self.assertRaises(BufferReadError):
+ buf.pull_bytes(2)
- pull_bytes(buf, 2)
self.assertEqual(buf.tell(), 0)
===========changed ref 3===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint8(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint8(), 0x08)
- self.assertEqual(pull_uint8(buf), 0x08)
self.assertEqual(buf.tell(), 1)
===========changed ref 4===========
# module: tests.test_buffer
class BufferTest(TestCase):
+ def test_data_slice(self):
+ buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.data_slice(1, 3), b"\x07\x06")
+
===========changed ref 5===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_bytes(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_bytes(3), b"\x08\x07\x06")
- self.assertEqual(pull_bytes(buf, 3), b"\x08\x07\x06")
===========changed ref 6===========
# module: aioquic.tls
def pull_group(buf: Buffer) -> Group:
+ return Group(buf.pull_uint16())
- return Group(pull_uint16(buf))
===========changed ref 7===========
# module: aioquic.tls
def pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm:
+ return SignatureAlgorithm(buf.pull_uint16())
- return SignatureAlgorithm(pull_uint16(buf))
===========changed ref 8===========
# module: aioquic.tls
def pull_compression_method(buf: Buffer) -> CompressionMethod:
+ return CompressionMethod(buf.pull_uint8())
- return CompressionMethod(pull_uint8(buf))
===========changed ref 9===========
# module: aioquic.tls
# INTEGERS
def pull_cipher_suite(buf: Buffer) -> CipherSuite:
+ return CipherSuite(buf.pull_uint16())
- return CipherSuite(pull_uint16(buf))
===========changed ref 10===========
# module: aioquic.tls
def pull_key_exchange_mode(buf: Buffer) -> KeyExchangeMode:
+ return KeyExchangeMode(buf.pull_uint8())
- return KeyExchangeMode(pull_uint8(buf))
===========changed ref 11===========
# module: aioquic.buffer
class Buffer:
+ def push_uint8(self, v: int) -> None:
+ """
+ Push an 8-bit unsigned integer.
+ """
+ self._data[self._pos] = v
+ self._pos += 1
+
===========changed ref 12===========
# module: aioquic.tls
def push_key_share(buf: Buffer, value: KeyShareEntry) -> None:
+ buf.push_uint16(value[0])
- push_group(buf, value[0])
push_opaque(buf, 2, value[1])
===========changed ref 13===========
# module: aioquic.tls
@contextmanager
def push_extension(buf: Buffer, extension_type: int) -> Generator:
+ buf.push_uint16(extension_type)
- push_uint16(buf, extension_type)
with push_block(buf, 2):
yield
===========changed ref 14===========
# module: aioquic.buffer
- def push_uint8(buf: Buffer, v: int) -> None:
- """
- Push an 8-bit unsigned integer.
- """
- buf._data[buf._pos] = v
- buf._pos += 1
-
===========changed ref 15===========
# module: aioquic.tls
def push_psk_identity(buf: Buffer, entry: PskIdentity) -> None:
push_opaque(buf, 2, entry[0])
+ buf.push_uint32(entry[1])
- push_uint32(buf, entry[1])
===========changed ref 16===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_data_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a DATA_BLOCKED frame.
"""
+ buf.pull_uint_var() # limit
- pull_uint_var(buf) # limit
===========changed ref 17===========
# module: aioquic.buffer
class Buffer:
+ def push_uint64(self, v: int) -> None:
+ """
+ Push a 64-bit unsigned integer.
+ """
+ pack_into("!Q", self._data, self._pos, v)
+ self._pos += 8
+
===========changed ref 18===========
# module: aioquic.buffer
class Buffer:
+ def push_uint32(self, v: int) -> None:
+ """
+ Push a 32-bit unsigned integer.
+ """
+ pack_into("!L", self._data, self._pos, v)
+ self._pos += 4
+
===========changed ref 19===========
# module: aioquic.buffer
class Buffer:
+ def push_uint16(self, v: int) -> None:
+ """
+ Push a 16-bit unsigned integer.
+ """
+ pack_into("!H", self._data, self._pos, v)
+ self._pos += 2
+
===========changed ref 20===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_streams_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a STREAMS_BLOCKED frame.
"""
+ buf.pull_uint_var() # limit
- pull_uint_var(buf) # limit
===========changed ref 21===========
# module: aioquic.tls
def push_list(
+ buf: Buffer, capacity: int, func: Callable[[T], None], values: Sequence[T]
- buf: Buffer, capacity: int, func: Callable[[Buffer, T], None], values: Sequence[T]
) -> None:
"""
Push a list of items.
"""
with push_block(buf, capacity):
for value in values:
+ func(value)
- func(buf, value)
===========changed ref 22===========
# module: aioquic.packet
def pull_new_token_frame(buf: Buffer) -> bytes:
+ length = buf.pull_uint_var()
- length = pull_uint_var(buf)
+ return buf.pull_bytes(length)
- return pull_bytes(buf, length)
|
tests.test_buffer/BufferTest.test_pull_uint16_truncated
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<2>:<add> buf.pull_uint16()
<del> pull_uint16(buf)
|
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint16_truncated(self):
<0> buf = Buffer(capacity=1)
<1> with self.assertRaises(BufferReadError):
<2> pull_uint16(buf)
<3> self.assertEqual(buf.tell(), 0)
<4>
|
===========unchanged ref 0===========
at: aioquic.buffer
BufferReadError(*args: object)
at: aioquic.buffer.Buffer
tell() -> int
pull_uint32() -> int
at: tests.test_buffer.BufferTest.test_pull_uint32_truncated
buf = Buffer(capacity=3)
at: unittest.case.TestCase
assertEqual(first: Any, second: Any, msg: Any=...) -> None
assertRaises(expected_exception: Union[Type[_E], Tuple[Type[_E], ...]], msg: Any=...) -> _AssertRaisesContext[_E]
assertRaises(expected_exception: Union[Type[BaseException], Tuple[Type[BaseException], ...]], callable: Callable[..., Any], *args: Any, **kwargs: Any) -> None
===========changed ref 0===========
# module: aioquic.buffer
class Buffer:
+ def pull_uint32(self) -> int:
+ """
+ Pull a 32-bit unsigned integer.
+ """
+ try:
+ v, = struct.unpack_from("!L", self._data, self._pos)
+ self._pos += 4
+ return v
+ except struct.error:
+ raise BufferReadError
+
===========changed ref 1===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint8_truncated(self):
buf = Buffer(capacity=0)
with self.assertRaises(BufferReadError):
+ buf.pull_uint8()
- pull_uint8(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 2===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_bytes_truncated(self):
buf = Buffer(capacity=0)
with self.assertRaises(BufferReadError):
+ buf.pull_bytes(2)
- pull_bytes(buf, 2)
self.assertEqual(buf.tell(), 0)
===========changed ref 3===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint16(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint16(), 0x0807)
- self.assertEqual(pull_uint16(buf), 0x0807)
self.assertEqual(buf.tell(), 2)
===========changed ref 4===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint8(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint8(), 0x08)
- self.assertEqual(pull_uint8(buf), 0x08)
self.assertEqual(buf.tell(), 1)
===========changed ref 5===========
# module: tests.test_buffer
class BufferTest(TestCase):
+ def test_data_slice(self):
+ buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.data_slice(1, 3), b"\x07\x06")
+
===========changed ref 6===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_bytes(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_bytes(3), b"\x08\x07\x06")
- self.assertEqual(pull_bytes(buf, 3), b"\x08\x07\x06")
===========changed ref 7===========
# module: aioquic.tls
def pull_group(buf: Buffer) -> Group:
+ return Group(buf.pull_uint16())
- return Group(pull_uint16(buf))
===========changed ref 8===========
# module: aioquic.tls
def pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm:
+ return SignatureAlgorithm(buf.pull_uint16())
- return SignatureAlgorithm(pull_uint16(buf))
===========changed ref 9===========
# module: aioquic.tls
def pull_compression_method(buf: Buffer) -> CompressionMethod:
+ return CompressionMethod(buf.pull_uint8())
- return CompressionMethod(pull_uint8(buf))
===========changed ref 10===========
# module: aioquic.tls
# INTEGERS
def pull_cipher_suite(buf: Buffer) -> CipherSuite:
+ return CipherSuite(buf.pull_uint16())
- return CipherSuite(pull_uint16(buf))
===========changed ref 11===========
# module: aioquic.tls
def pull_key_exchange_mode(buf: Buffer) -> KeyExchangeMode:
+ return KeyExchangeMode(buf.pull_uint8())
- return KeyExchangeMode(pull_uint8(buf))
===========changed ref 12===========
# module: aioquic.buffer
class Buffer:
+ def push_uint8(self, v: int) -> None:
+ """
+ Push an 8-bit unsigned integer.
+ """
+ self._data[self._pos] = v
+ self._pos += 1
+
===========changed ref 13===========
# module: aioquic.tls
def push_key_share(buf: Buffer, value: KeyShareEntry) -> None:
+ buf.push_uint16(value[0])
- push_group(buf, value[0])
push_opaque(buf, 2, value[1])
===========changed ref 14===========
# module: aioquic.tls
@contextmanager
def push_extension(buf: Buffer, extension_type: int) -> Generator:
+ buf.push_uint16(extension_type)
- push_uint16(buf, extension_type)
with push_block(buf, 2):
yield
===========changed ref 15===========
# module: aioquic.buffer
- def push_uint8(buf: Buffer, v: int) -> None:
- """
- Push an 8-bit unsigned integer.
- """
- buf._data[buf._pos] = v
- buf._pos += 1
-
===========changed ref 16===========
# module: aioquic.tls
def push_psk_identity(buf: Buffer, entry: PskIdentity) -> None:
push_opaque(buf, 2, entry[0])
+ buf.push_uint32(entry[1])
- push_uint32(buf, entry[1])
===========changed ref 17===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_data_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a DATA_BLOCKED frame.
"""
+ buf.pull_uint_var() # limit
- pull_uint_var(buf) # limit
===========changed ref 18===========
# module: aioquic.buffer
class Buffer:
+ def push_uint64(self, v: int) -> None:
+ """
+ Push a 64-bit unsigned integer.
+ """
+ pack_into("!Q", self._data, self._pos, v)
+ self._pos += 8
+
===========changed ref 19===========
# module: aioquic.buffer
class Buffer:
+ def push_uint32(self, v: int) -> None:
+ """
+ Push a 32-bit unsigned integer.
+ """
+ pack_into("!L", self._data, self._pos, v)
+ self._pos += 4
+
===========changed ref 20===========
# module: aioquic.buffer
class Buffer:
+ def push_uint16(self, v: int) -> None:
+ """
+ Push a 16-bit unsigned integer.
+ """
+ pack_into("!H", self._data, self._pos, v)
+ self._pos += 2
+
===========changed ref 21===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_streams_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a STREAMS_BLOCKED frame.
"""
+ buf.pull_uint_var() # limit
- pull_uint_var(buf) # limit
|
tests.test_buffer/BufferTest.test_pull_uint32
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<1>:<add> self.assertEqual(buf.pull_uint32(), 0x08070605)
<del> self.assertEqual(pull_uint32(buf), 0x08070605)
|
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint32(self):
<0> buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
<1> self.assertEqual(pull_uint32(buf), 0x08070605)
<2> self.assertEqual(buf.tell(), 4)
<3>
|
===========unchanged ref 0===========
at: aioquic.buffer.Buffer
tell() -> int
pull_uint64() -> int
at: tests.test_buffer.BufferTest.test_pull_uint64
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
at: unittest.case.TestCase
assertEqual(first: Any, second: Any, msg: Any=...) -> None
===========changed ref 0===========
# module: aioquic.buffer
class Buffer:
+ def pull_uint64(self) -> int:
+ """
+ Pull a 64-bit unsigned integer.
+ """
+ try:
+ v, = unpack_from("!Q", self._data, self._pos)
+ self._pos += 8
+ return v
+ except struct.error:
+ raise BufferReadError
+
===========changed ref 1===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint16_truncated(self):
buf = Buffer(capacity=1)
with self.assertRaises(BufferReadError):
+ buf.pull_uint16()
- pull_uint16(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 2===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint8_truncated(self):
buf = Buffer(capacity=0)
with self.assertRaises(BufferReadError):
+ buf.pull_uint8()
- pull_uint8(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 3===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_bytes_truncated(self):
buf = Buffer(capacity=0)
with self.assertRaises(BufferReadError):
+ buf.pull_bytes(2)
- pull_bytes(buf, 2)
self.assertEqual(buf.tell(), 0)
===========changed ref 4===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint16(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint16(), 0x0807)
- self.assertEqual(pull_uint16(buf), 0x0807)
self.assertEqual(buf.tell(), 2)
===========changed ref 5===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint8(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint8(), 0x08)
- self.assertEqual(pull_uint8(buf), 0x08)
self.assertEqual(buf.tell(), 1)
===========changed ref 6===========
# module: tests.test_buffer
class BufferTest(TestCase):
+ def test_data_slice(self):
+ buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.data_slice(1, 3), b"\x07\x06")
+
===========changed ref 7===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_bytes(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_bytes(3), b"\x08\x07\x06")
- self.assertEqual(pull_bytes(buf, 3), b"\x08\x07\x06")
===========changed ref 8===========
# module: aioquic.tls
def pull_group(buf: Buffer) -> Group:
+ return Group(buf.pull_uint16())
- return Group(pull_uint16(buf))
===========changed ref 9===========
# module: aioquic.tls
def pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm:
+ return SignatureAlgorithm(buf.pull_uint16())
- return SignatureAlgorithm(pull_uint16(buf))
===========changed ref 10===========
# module: aioquic.tls
def pull_compression_method(buf: Buffer) -> CompressionMethod:
+ return CompressionMethod(buf.pull_uint8())
- return CompressionMethod(pull_uint8(buf))
===========changed ref 11===========
# module: aioquic.tls
# INTEGERS
def pull_cipher_suite(buf: Buffer) -> CipherSuite:
+ return CipherSuite(buf.pull_uint16())
- return CipherSuite(pull_uint16(buf))
===========changed ref 12===========
# module: aioquic.tls
def pull_key_exchange_mode(buf: Buffer) -> KeyExchangeMode:
+ return KeyExchangeMode(buf.pull_uint8())
- return KeyExchangeMode(pull_uint8(buf))
===========changed ref 13===========
# module: aioquic.buffer
class Buffer:
+ def push_uint8(self, v: int) -> None:
+ """
+ Push an 8-bit unsigned integer.
+ """
+ self._data[self._pos] = v
+ self._pos += 1
+
===========changed ref 14===========
# module: aioquic.tls
def push_key_share(buf: Buffer, value: KeyShareEntry) -> None:
+ buf.push_uint16(value[0])
- push_group(buf, value[0])
push_opaque(buf, 2, value[1])
===========changed ref 15===========
# module: aioquic.tls
@contextmanager
def push_extension(buf: Buffer, extension_type: int) -> Generator:
+ buf.push_uint16(extension_type)
- push_uint16(buf, extension_type)
with push_block(buf, 2):
yield
===========changed ref 16===========
# module: aioquic.buffer
- def push_uint8(buf: Buffer, v: int) -> None:
- """
- Push an 8-bit unsigned integer.
- """
- buf._data[buf._pos] = v
- buf._pos += 1
-
===========changed ref 17===========
# module: aioquic.tls
def push_psk_identity(buf: Buffer, entry: PskIdentity) -> None:
push_opaque(buf, 2, entry[0])
+ buf.push_uint32(entry[1])
- push_uint32(buf, entry[1])
===========changed ref 18===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_data_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a DATA_BLOCKED frame.
"""
+ buf.pull_uint_var() # limit
- pull_uint_var(buf) # limit
===========changed ref 19===========
# module: aioquic.buffer
class Buffer:
+ def push_uint64(self, v: int) -> None:
+ """
+ Push a 64-bit unsigned integer.
+ """
+ pack_into("!Q", self._data, self._pos, v)
+ self._pos += 8
+
===========changed ref 20===========
# module: aioquic.buffer
class Buffer:
+ def push_uint32(self, v: int) -> None:
+ """
+ Push a 32-bit unsigned integer.
+ """
+ pack_into("!L", self._data, self._pos, v)
+ self._pos += 4
+
===========changed ref 21===========
# module: aioquic.buffer
class Buffer:
+ def push_uint16(self, v: int) -> None:
+ """
+ Push a 16-bit unsigned integer.
+ """
+ pack_into("!H", self._data, self._pos, v)
+ self._pos += 2
+
===========changed ref 22===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_streams_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a STREAMS_BLOCKED frame.
"""
+ buf.pull_uint_var() # limit
- pull_uint_var(buf) # limit
|
tests.test_buffer/BufferTest.test_pull_uint32_truncated
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<2>:<add> buf.pull_uint32()
<del> pull_uint32(buf)
|
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint32_truncated(self):
<0> buf = Buffer(capacity=3)
<1> with self.assertRaises(BufferReadError):
<2> pull_uint32(buf)
<3> self.assertEqual(buf.tell(), 0)
<4>
|
===========unchanged ref 0===========
at: aioquic.buffer
BufferReadError(*args: object)
at: aioquic.buffer.Buffer
tell() -> int
pull_uint64() -> int
at: tests.test_buffer.BufferTest.test_pull_uint64_truncated
buf = Buffer(capacity=7)
at: unittest.case.TestCase
assertEqual(first: Any, second: Any, msg: Any=...) -> None
assertRaises(expected_exception: Union[Type[_E], Tuple[Type[_E], ...]], msg: Any=...) -> _AssertRaisesContext[_E]
assertRaises(expected_exception: Union[Type[BaseException], Tuple[Type[BaseException], ...]], callable: Callable[..., Any], *args: Any, **kwargs: Any) -> None
===========changed ref 0===========
# module: aioquic.buffer
class Buffer:
+ def pull_uint64(self) -> int:
+ """
+ Pull a 64-bit unsigned integer.
+ """
+ try:
+ v, = unpack_from("!Q", self._data, self._pos)
+ self._pos += 8
+ return v
+ except struct.error:
+ raise BufferReadError
+
===========changed ref 1===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint16_truncated(self):
buf = Buffer(capacity=1)
with self.assertRaises(BufferReadError):
+ buf.pull_uint16()
- pull_uint16(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 2===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint8_truncated(self):
buf = Buffer(capacity=0)
with self.assertRaises(BufferReadError):
+ buf.pull_uint8()
- pull_uint8(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 3===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_bytes_truncated(self):
buf = Buffer(capacity=0)
with self.assertRaises(BufferReadError):
+ buf.pull_bytes(2)
- pull_bytes(buf, 2)
self.assertEqual(buf.tell(), 0)
===========changed ref 4===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint32(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint32(), 0x08070605)
- self.assertEqual(pull_uint32(buf), 0x08070605)
self.assertEqual(buf.tell(), 4)
===========changed ref 5===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint16(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint16(), 0x0807)
- self.assertEqual(pull_uint16(buf), 0x0807)
self.assertEqual(buf.tell(), 2)
===========changed ref 6===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint8(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint8(), 0x08)
- self.assertEqual(pull_uint8(buf), 0x08)
self.assertEqual(buf.tell(), 1)
===========changed ref 7===========
# module: tests.test_buffer
class BufferTest(TestCase):
+ def test_data_slice(self):
+ buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.data_slice(1, 3), b"\x07\x06")
+
===========changed ref 8===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_bytes(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_bytes(3), b"\x08\x07\x06")
- self.assertEqual(pull_bytes(buf, 3), b"\x08\x07\x06")
===========changed ref 9===========
# module: aioquic.tls
def pull_group(buf: Buffer) -> Group:
+ return Group(buf.pull_uint16())
- return Group(pull_uint16(buf))
===========changed ref 10===========
# module: aioquic.tls
def pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm:
+ return SignatureAlgorithm(buf.pull_uint16())
- return SignatureAlgorithm(pull_uint16(buf))
===========changed ref 11===========
# module: aioquic.tls
def pull_compression_method(buf: Buffer) -> CompressionMethod:
+ return CompressionMethod(buf.pull_uint8())
- return CompressionMethod(pull_uint8(buf))
===========changed ref 12===========
# module: aioquic.tls
# INTEGERS
def pull_cipher_suite(buf: Buffer) -> CipherSuite:
+ return CipherSuite(buf.pull_uint16())
- return CipherSuite(pull_uint16(buf))
===========changed ref 13===========
# module: aioquic.tls
def pull_key_exchange_mode(buf: Buffer) -> KeyExchangeMode:
+ return KeyExchangeMode(buf.pull_uint8())
- return KeyExchangeMode(pull_uint8(buf))
===========changed ref 14===========
# module: aioquic.buffer
class Buffer:
+ def push_uint8(self, v: int) -> None:
+ """
+ Push an 8-bit unsigned integer.
+ """
+ self._data[self._pos] = v
+ self._pos += 1
+
===========changed ref 15===========
# module: aioquic.tls
def push_key_share(buf: Buffer, value: KeyShareEntry) -> None:
+ buf.push_uint16(value[0])
- push_group(buf, value[0])
push_opaque(buf, 2, value[1])
===========changed ref 16===========
# module: aioquic.tls
@contextmanager
def push_extension(buf: Buffer, extension_type: int) -> Generator:
+ buf.push_uint16(extension_type)
- push_uint16(buf, extension_type)
with push_block(buf, 2):
yield
===========changed ref 17===========
# module: aioquic.buffer
- def push_uint8(buf: Buffer, v: int) -> None:
- """
- Push an 8-bit unsigned integer.
- """
- buf._data[buf._pos] = v
- buf._pos += 1
-
===========changed ref 18===========
# module: aioquic.tls
def push_psk_identity(buf: Buffer, entry: PskIdentity) -> None:
push_opaque(buf, 2, entry[0])
+ buf.push_uint32(entry[1])
- push_uint32(buf, entry[1])
===========changed ref 19===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_data_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a DATA_BLOCKED frame.
"""
+ buf.pull_uint_var() # limit
- pull_uint_var(buf) # limit
===========changed ref 20===========
# module: aioquic.buffer
class Buffer:
+ def push_uint64(self, v: int) -> None:
+ """
+ Push a 64-bit unsigned integer.
+ """
+ pack_into("!Q", self._data, self._pos, v)
+ self._pos += 8
+
|
tests.test_buffer/BufferTest.test_pull_uint64
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<1>:<add> self.assertEqual(buf.pull_uint64(), 0x0807060504030201)
<del> self.assertEqual(pull_uint64(buf), 0x0807060504030201)
|
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint64(self):
<0> buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
<1> self.assertEqual(pull_uint64(buf), 0x0807060504030201)
<2> self.assertEqual(buf.tell(), 8)
<3>
|
===========unchanged ref 0===========
at: aioquic.buffer.Buffer
tell() -> int
push_bytes(v: bytes) -> None
at: tests.test_buffer.BufferTest.test_push_bytes
buf = Buffer(capacity=3)
at: unittest.case.TestCase
assertEqual(first: Any, second: Any, msg: Any=...) -> None
===========changed ref 0===========
# module: aioquic.buffer
class Buffer:
+ def push_bytes(self, v: bytes) -> None:
+ """
+ Push bytes.
+ """
+ end = self._pos + len(v)
+ if end > self._length:
+ raise BufferWriteError
+ self._data[self._pos : end] = v
+ self._pos = end
+
===========changed ref 1===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint32_truncated(self):
buf = Buffer(capacity=3)
with self.assertRaises(BufferReadError):
+ buf.pull_uint32()
- pull_uint32(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 2===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint16_truncated(self):
buf = Buffer(capacity=1)
with self.assertRaises(BufferReadError):
+ buf.pull_uint16()
- pull_uint16(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 3===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint8_truncated(self):
buf = Buffer(capacity=0)
with self.assertRaises(BufferReadError):
+ buf.pull_uint8()
- pull_uint8(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 4===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_bytes_truncated(self):
buf = Buffer(capacity=0)
with self.assertRaises(BufferReadError):
+ buf.pull_bytes(2)
- pull_bytes(buf, 2)
self.assertEqual(buf.tell(), 0)
===========changed ref 5===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint32(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint32(), 0x08070605)
- self.assertEqual(pull_uint32(buf), 0x08070605)
self.assertEqual(buf.tell(), 4)
===========changed ref 6===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint16(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint16(), 0x0807)
- self.assertEqual(pull_uint16(buf), 0x0807)
self.assertEqual(buf.tell(), 2)
===========changed ref 7===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint8(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint8(), 0x08)
- self.assertEqual(pull_uint8(buf), 0x08)
self.assertEqual(buf.tell(), 1)
===========changed ref 8===========
# module: tests.test_buffer
class BufferTest(TestCase):
+ def test_data_slice(self):
+ buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.data_slice(1, 3), b"\x07\x06")
+
===========changed ref 9===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_bytes(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_bytes(3), b"\x08\x07\x06")
- self.assertEqual(pull_bytes(buf, 3), b"\x08\x07\x06")
===========changed ref 10===========
# module: aioquic.tls
def pull_group(buf: Buffer) -> Group:
+ return Group(buf.pull_uint16())
- return Group(pull_uint16(buf))
===========changed ref 11===========
# module: aioquic.tls
def pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm:
+ return SignatureAlgorithm(buf.pull_uint16())
- return SignatureAlgorithm(pull_uint16(buf))
===========changed ref 12===========
# module: aioquic.tls
def pull_compression_method(buf: Buffer) -> CompressionMethod:
+ return CompressionMethod(buf.pull_uint8())
- return CompressionMethod(pull_uint8(buf))
===========changed ref 13===========
# module: aioquic.tls
# INTEGERS
def pull_cipher_suite(buf: Buffer) -> CipherSuite:
+ return CipherSuite(buf.pull_uint16())
- return CipherSuite(pull_uint16(buf))
===========changed ref 14===========
# module: aioquic.tls
def pull_key_exchange_mode(buf: Buffer) -> KeyExchangeMode:
+ return KeyExchangeMode(buf.pull_uint8())
- return KeyExchangeMode(pull_uint8(buf))
===========changed ref 15===========
# module: aioquic.buffer
class Buffer:
+ def push_uint8(self, v: int) -> None:
+ """
+ Push an 8-bit unsigned integer.
+ """
+ self._data[self._pos] = v
+ self._pos += 1
+
===========changed ref 16===========
# module: aioquic.tls
def push_key_share(buf: Buffer, value: KeyShareEntry) -> None:
+ buf.push_uint16(value[0])
- push_group(buf, value[0])
push_opaque(buf, 2, value[1])
===========changed ref 17===========
# module: aioquic.tls
@contextmanager
def push_extension(buf: Buffer, extension_type: int) -> Generator:
+ buf.push_uint16(extension_type)
- push_uint16(buf, extension_type)
with push_block(buf, 2):
yield
===========changed ref 18===========
# module: aioquic.buffer
- def push_uint8(buf: Buffer, v: int) -> None:
- """
- Push an 8-bit unsigned integer.
- """
- buf._data[buf._pos] = v
- buf._pos += 1
-
===========changed ref 19===========
# module: aioquic.tls
def push_psk_identity(buf: Buffer, entry: PskIdentity) -> None:
push_opaque(buf, 2, entry[0])
+ buf.push_uint32(entry[1])
- push_uint32(buf, entry[1])
===========changed ref 20===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_data_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a DATA_BLOCKED frame.
"""
+ buf.pull_uint_var() # limit
- pull_uint_var(buf) # limit
===========changed ref 21===========
# module: aioquic.buffer
class Buffer:
+ def push_uint64(self, v: int) -> None:
+ """
+ Push a 64-bit unsigned integer.
+ """
+ pack_into("!Q", self._data, self._pos, v)
+ self._pos += 8
+
|
tests.test_buffer/BufferTest.test_pull_uint64_truncated
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<2>:<add> buf.pull_uint64()
<del> pull_uint64(buf)
|
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint64_truncated(self):
<0> buf = Buffer(capacity=7)
<1> with self.assertRaises(BufferReadError):
<2> pull_uint64(buf)
<3> self.assertEqual(buf.tell(), 0)
<4>
|
===========unchanged ref 0===========
at: aioquic.buffer
BufferWriteError(*args: object)
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic.buffer.Buffer
tell() -> int
push_bytes(v: bytes) -> None
at: unittest.case.TestCase
assertEqual(first: Any, second: Any, msg: Any=...) -> None
assertRaises(expected_exception: Union[Type[_E], Tuple[Type[_E], ...]], msg: Any=...) -> _AssertRaisesContext[_E]
assertRaises(expected_exception: Union[Type[BaseException], Tuple[Type[BaseException], ...]], callable: Callable[..., Any], *args: Any, **kwargs: Any) -> None
===========changed ref 0===========
# module: aioquic.buffer
class Buffer:
+ def push_bytes(self, v: bytes) -> None:
+ """
+ Push bytes.
+ """
+ end = self._pos + len(v)
+ if end > self._length:
+ raise BufferWriteError
+ self._data[self._pos : end] = v
+ self._pos = end
+
===========changed ref 1===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint32_truncated(self):
buf = Buffer(capacity=3)
with self.assertRaises(BufferReadError):
+ buf.pull_uint32()
- pull_uint32(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 2===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint16_truncated(self):
buf = Buffer(capacity=1)
with self.assertRaises(BufferReadError):
+ buf.pull_uint16()
- pull_uint16(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 3===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint8_truncated(self):
buf = Buffer(capacity=0)
with self.assertRaises(BufferReadError):
+ buf.pull_uint8()
- pull_uint8(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 4===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_bytes_truncated(self):
buf = Buffer(capacity=0)
with self.assertRaises(BufferReadError):
+ buf.pull_bytes(2)
- pull_bytes(buf, 2)
self.assertEqual(buf.tell(), 0)
===========changed ref 5===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint64(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint64(), 0x0807060504030201)
- self.assertEqual(pull_uint64(buf), 0x0807060504030201)
self.assertEqual(buf.tell(), 8)
===========changed ref 6===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint32(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint32(), 0x08070605)
- self.assertEqual(pull_uint32(buf), 0x08070605)
self.assertEqual(buf.tell(), 4)
===========changed ref 7===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint16(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint16(), 0x0807)
- self.assertEqual(pull_uint16(buf), 0x0807)
self.assertEqual(buf.tell(), 2)
===========changed ref 8===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint8(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint8(), 0x08)
- self.assertEqual(pull_uint8(buf), 0x08)
self.assertEqual(buf.tell(), 1)
===========changed ref 9===========
# module: tests.test_buffer
class BufferTest(TestCase):
+ def test_data_slice(self):
+ buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.data_slice(1, 3), b"\x07\x06")
+
===========changed ref 10===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_bytes(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_bytes(3), b"\x08\x07\x06")
- self.assertEqual(pull_bytes(buf, 3), b"\x08\x07\x06")
===========changed ref 11===========
# module: aioquic.tls
def pull_group(buf: Buffer) -> Group:
+ return Group(buf.pull_uint16())
- return Group(pull_uint16(buf))
===========changed ref 12===========
# module: aioquic.tls
def pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm:
+ return SignatureAlgorithm(buf.pull_uint16())
- return SignatureAlgorithm(pull_uint16(buf))
===========changed ref 13===========
# module: aioquic.tls
def pull_compression_method(buf: Buffer) -> CompressionMethod:
+ return CompressionMethod(buf.pull_uint8())
- return CompressionMethod(pull_uint8(buf))
===========changed ref 14===========
# module: aioquic.tls
# INTEGERS
def pull_cipher_suite(buf: Buffer) -> CipherSuite:
+ return CipherSuite(buf.pull_uint16())
- return CipherSuite(pull_uint16(buf))
===========changed ref 15===========
# module: aioquic.tls
def pull_key_exchange_mode(buf: Buffer) -> KeyExchangeMode:
+ return KeyExchangeMode(buf.pull_uint8())
- return KeyExchangeMode(pull_uint8(buf))
===========changed ref 16===========
# module: aioquic.buffer
class Buffer:
+ def push_uint8(self, v: int) -> None:
+ """
+ Push an 8-bit unsigned integer.
+ """
+ self._data[self._pos] = v
+ self._pos += 1
+
===========changed ref 17===========
# module: aioquic.tls
def push_key_share(buf: Buffer, value: KeyShareEntry) -> None:
+ buf.push_uint16(value[0])
- push_group(buf, value[0])
push_opaque(buf, 2, value[1])
===========changed ref 18===========
# module: aioquic.tls
@contextmanager
def push_extension(buf: Buffer, extension_type: int) -> Generator:
+ buf.push_uint16(extension_type)
- push_uint16(buf, extension_type)
with push_block(buf, 2):
yield
===========changed ref 19===========
# module: aioquic.buffer
- def push_uint8(buf: Buffer, v: int) -> None:
- """
- Push an 8-bit unsigned integer.
- """
- buf._data[buf._pos] = v
- buf._pos += 1
-
===========changed ref 20===========
# module: aioquic.tls
def push_psk_identity(buf: Buffer, entry: PskIdentity) -> None:
push_opaque(buf, 2, entry[0])
+ buf.push_uint32(entry[1])
- push_uint32(buf, entry[1])
|
tests.test_buffer/BufferTest.test_push_bytes
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<1>:<add> buf.push_bytes(b"\x08\x07\x06")
<del> push_bytes(buf, b"\x08\x07\x06")
|
# module: tests.test_buffer
class BufferTest(TestCase):
def test_push_bytes(self):
<0> buf = Buffer(capacity=3)
<1> push_bytes(buf, b"\x08\x07\x06")
<2> self.assertEqual(buf.data, b"\x08\x07\x06")
<3> self.assertEqual(buf.tell(), 3)
<4>
|
===========unchanged ref 0===========
at: aioquic.buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic.buffer.Buffer
tell() -> int
push_uint8(v: int) -> None
at: unittest.case.TestCase
assertEqual(first: Any, second: Any, msg: Any=...) -> None
===========changed ref 0===========
# module: aioquic.buffer
class Buffer:
+ def push_uint8(self, v: int) -> None:
+ """
+ Push an 8-bit unsigned integer.
+ """
+ self._data[self._pos] = v
+ self._pos += 1
+
===========changed ref 1===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint64_truncated(self):
buf = Buffer(capacity=7)
with self.assertRaises(BufferReadError):
+ buf.pull_uint64()
- pull_uint64(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 2===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint32_truncated(self):
buf = Buffer(capacity=3)
with self.assertRaises(BufferReadError):
+ buf.pull_uint32()
- pull_uint32(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 3===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint16_truncated(self):
buf = Buffer(capacity=1)
with self.assertRaises(BufferReadError):
+ buf.pull_uint16()
- pull_uint16(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 4===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint8_truncated(self):
buf = Buffer(capacity=0)
with self.assertRaises(BufferReadError):
+ buf.pull_uint8()
- pull_uint8(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 5===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_bytes_truncated(self):
buf = Buffer(capacity=0)
with self.assertRaises(BufferReadError):
+ buf.pull_bytes(2)
- pull_bytes(buf, 2)
self.assertEqual(buf.tell(), 0)
===========changed ref 6===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint64(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint64(), 0x0807060504030201)
- self.assertEqual(pull_uint64(buf), 0x0807060504030201)
self.assertEqual(buf.tell(), 8)
===========changed ref 7===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint32(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint32(), 0x08070605)
- self.assertEqual(pull_uint32(buf), 0x08070605)
self.assertEqual(buf.tell(), 4)
===========changed ref 8===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint16(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint16(), 0x0807)
- self.assertEqual(pull_uint16(buf), 0x0807)
self.assertEqual(buf.tell(), 2)
===========changed ref 9===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint8(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint8(), 0x08)
- self.assertEqual(pull_uint8(buf), 0x08)
self.assertEqual(buf.tell(), 1)
===========changed ref 10===========
# module: tests.test_buffer
class BufferTest(TestCase):
+ def test_data_slice(self):
+ buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.data_slice(1, 3), b"\x07\x06")
+
===========changed ref 11===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_bytes(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_bytes(3), b"\x08\x07\x06")
- self.assertEqual(pull_bytes(buf, 3), b"\x08\x07\x06")
===========changed ref 12===========
# module: aioquic.tls
def pull_group(buf: Buffer) -> Group:
+ return Group(buf.pull_uint16())
- return Group(pull_uint16(buf))
===========changed ref 13===========
# module: aioquic.tls
def pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm:
+ return SignatureAlgorithm(buf.pull_uint16())
- return SignatureAlgorithm(pull_uint16(buf))
===========changed ref 14===========
# module: aioquic.tls
def pull_compression_method(buf: Buffer) -> CompressionMethod:
+ return CompressionMethod(buf.pull_uint8())
- return CompressionMethod(pull_uint8(buf))
===========changed ref 15===========
# module: aioquic.tls
# INTEGERS
def pull_cipher_suite(buf: Buffer) -> CipherSuite:
+ return CipherSuite(buf.pull_uint16())
- return CipherSuite(pull_uint16(buf))
===========changed ref 16===========
# module: aioquic.tls
def pull_key_exchange_mode(buf: Buffer) -> KeyExchangeMode:
+ return KeyExchangeMode(buf.pull_uint8())
- return KeyExchangeMode(pull_uint8(buf))
===========changed ref 17===========
# module: aioquic.tls
def push_key_share(buf: Buffer, value: KeyShareEntry) -> None:
+ buf.push_uint16(value[0])
- push_group(buf, value[0])
push_opaque(buf, 2, value[1])
===========changed ref 18===========
# module: aioquic.tls
@contextmanager
def push_extension(buf: Buffer, extension_type: int) -> Generator:
+ buf.push_uint16(extension_type)
- push_uint16(buf, extension_type)
with push_block(buf, 2):
yield
===========changed ref 19===========
# module: aioquic.buffer
- def push_uint8(buf: Buffer, v: int) -> None:
- """
- Push an 8-bit unsigned integer.
- """
- buf._data[buf._pos] = v
- buf._pos += 1
-
===========changed ref 20===========
# module: aioquic.tls
def push_psk_identity(buf: Buffer, entry: PskIdentity) -> None:
push_opaque(buf, 2, entry[0])
+ buf.push_uint32(entry[1])
- push_uint32(buf, entry[1])
===========changed ref 21===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_data_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a DATA_BLOCKED frame.
"""
+ buf.pull_uint_var() # limit
- pull_uint_var(buf) # limit
|
tests.test_buffer/BufferTest.test_push_bytes_truncated
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<2>:<add> buf.push_bytes(b"\x08\x07\x06\x05")
<del> push_bytes(buf, b"\x08\x07\x06\x05")
|
# module: tests.test_buffer
class BufferTest(TestCase):
def test_push_bytes_truncated(self):
<0> buf = Buffer(capacity=3)
<1> with self.assertRaises(BufferWriteError):
<2> push_bytes(buf, b"\x08\x07\x06\x05")
<3> self.assertEqual(buf.tell(), 0)
<4>
|
===========unchanged ref 0===========
at: aioquic.buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic.buffer.Buffer
tell() -> int
push_uint16(v: int) -> None
at: unittest.case.TestCase
assertEqual(first: Any, second: Any, msg: Any=...) -> None
===========changed ref 0===========
# module: aioquic.buffer
class Buffer:
+ def push_uint16(self, v: int) -> None:
+ """
+ Push a 16-bit unsigned integer.
+ """
+ pack_into("!H", self._data, self._pos, v)
+ self._pos += 2
+
===========changed ref 1===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint64_truncated(self):
buf = Buffer(capacity=7)
with self.assertRaises(BufferReadError):
+ buf.pull_uint64()
- pull_uint64(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 2===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint32_truncated(self):
buf = Buffer(capacity=3)
with self.assertRaises(BufferReadError):
+ buf.pull_uint32()
- pull_uint32(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 3===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint16_truncated(self):
buf = Buffer(capacity=1)
with self.assertRaises(BufferReadError):
+ buf.pull_uint16()
- pull_uint16(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 4===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_push_bytes(self):
buf = Buffer(capacity=3)
+ buf.push_bytes(b"\x08\x07\x06")
- push_bytes(buf, b"\x08\x07\x06")
self.assertEqual(buf.data, b"\x08\x07\x06")
self.assertEqual(buf.tell(), 3)
===========changed ref 5===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint8_truncated(self):
buf = Buffer(capacity=0)
with self.assertRaises(BufferReadError):
+ buf.pull_uint8()
- pull_uint8(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 6===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_bytes_truncated(self):
buf = Buffer(capacity=0)
with self.assertRaises(BufferReadError):
+ buf.pull_bytes(2)
- pull_bytes(buf, 2)
self.assertEqual(buf.tell(), 0)
===========changed ref 7===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint64(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint64(), 0x0807060504030201)
- self.assertEqual(pull_uint64(buf), 0x0807060504030201)
self.assertEqual(buf.tell(), 8)
===========changed ref 8===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint32(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint32(), 0x08070605)
- self.assertEqual(pull_uint32(buf), 0x08070605)
self.assertEqual(buf.tell(), 4)
===========changed ref 9===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint16(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint16(), 0x0807)
- self.assertEqual(pull_uint16(buf), 0x0807)
self.assertEqual(buf.tell(), 2)
===========changed ref 10===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint8(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint8(), 0x08)
- self.assertEqual(pull_uint8(buf), 0x08)
self.assertEqual(buf.tell(), 1)
===========changed ref 11===========
# module: tests.test_buffer
class BufferTest(TestCase):
+ def test_data_slice(self):
+ buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.data_slice(1, 3), b"\x07\x06")
+
===========changed ref 12===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_bytes(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_bytes(3), b"\x08\x07\x06")
- self.assertEqual(pull_bytes(buf, 3), b"\x08\x07\x06")
===========changed ref 13===========
# module: aioquic.tls
def pull_group(buf: Buffer) -> Group:
+ return Group(buf.pull_uint16())
- return Group(pull_uint16(buf))
===========changed ref 14===========
# module: aioquic.tls
def pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm:
+ return SignatureAlgorithm(buf.pull_uint16())
- return SignatureAlgorithm(pull_uint16(buf))
===========changed ref 15===========
# module: aioquic.tls
def pull_compression_method(buf: Buffer) -> CompressionMethod:
+ return CompressionMethod(buf.pull_uint8())
- return CompressionMethod(pull_uint8(buf))
===========changed ref 16===========
# module: aioquic.tls
# INTEGERS
def pull_cipher_suite(buf: Buffer) -> CipherSuite:
+ return CipherSuite(buf.pull_uint16())
- return CipherSuite(pull_uint16(buf))
===========changed ref 17===========
# module: aioquic.tls
def pull_key_exchange_mode(buf: Buffer) -> KeyExchangeMode:
+ return KeyExchangeMode(buf.pull_uint8())
- return KeyExchangeMode(pull_uint8(buf))
===========changed ref 18===========
# module: aioquic.buffer
class Buffer:
+ def push_uint8(self, v: int) -> None:
+ """
+ Push an 8-bit unsigned integer.
+ """
+ self._data[self._pos] = v
+ self._pos += 1
+
===========changed ref 19===========
# module: aioquic.tls
def push_key_share(buf: Buffer, value: KeyShareEntry) -> None:
+ buf.push_uint16(value[0])
- push_group(buf, value[0])
push_opaque(buf, 2, value[1])
===========changed ref 20===========
# module: aioquic.tls
@contextmanager
def push_extension(buf: Buffer, extension_type: int) -> Generator:
+ buf.push_uint16(extension_type)
- push_uint16(buf, extension_type)
with push_block(buf, 2):
yield
===========changed ref 21===========
# module: aioquic.buffer
- def push_uint8(buf: Buffer, v: int) -> None:
- """
- Push an 8-bit unsigned integer.
- """
- buf._data[buf._pos] = v
- buf._pos += 1
-
|
tests.test_buffer/BufferTest.test_push_uint8
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<1>:<add> buf.push_uint8(0x08)
<del> push_uint8(buf, 0x08)
|
# module: tests.test_buffer
class BufferTest(TestCase):
def test_push_uint8(self):
<0> buf = Buffer(capacity=1)
<1> push_uint8(buf, 0x08)
<2> self.assertEqual(buf.data, b"\x08")
<3> self.assertEqual(buf.tell(), 1)
<4>
|
===========unchanged ref 0===========
at: aioquic.buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic.buffer.Buffer
tell() -> int
push_uint32(v: int) -> None
at: unittest.case.TestCase
assertEqual(first: Any, second: Any, msg: Any=...) -> None
===========changed ref 0===========
# module: aioquic.buffer
class Buffer:
+ def push_uint32(self, v: int) -> None:
+ """
+ Push a 32-bit unsigned integer.
+ """
+ pack_into("!L", self._data, self._pos, v)
+ self._pos += 4
+
===========changed ref 1===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint64_truncated(self):
buf = Buffer(capacity=7)
with self.assertRaises(BufferReadError):
+ buf.pull_uint64()
- pull_uint64(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 2===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint32_truncated(self):
buf = Buffer(capacity=3)
with self.assertRaises(BufferReadError):
+ buf.pull_uint32()
- pull_uint32(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 3===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_push_bytes_truncated(self):
buf = Buffer(capacity=3)
with self.assertRaises(BufferWriteError):
+ buf.push_bytes(b"\x08\x07\x06\x05")
- push_bytes(buf, b"\x08\x07\x06\x05")
self.assertEqual(buf.tell(), 0)
===========changed ref 4===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint16_truncated(self):
buf = Buffer(capacity=1)
with self.assertRaises(BufferReadError):
+ buf.pull_uint16()
- pull_uint16(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 5===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_push_bytes(self):
buf = Buffer(capacity=3)
+ buf.push_bytes(b"\x08\x07\x06")
- push_bytes(buf, b"\x08\x07\x06")
self.assertEqual(buf.data, b"\x08\x07\x06")
self.assertEqual(buf.tell(), 3)
===========changed ref 6===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint8_truncated(self):
buf = Buffer(capacity=0)
with self.assertRaises(BufferReadError):
+ buf.pull_uint8()
- pull_uint8(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 7===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_bytes_truncated(self):
buf = Buffer(capacity=0)
with self.assertRaises(BufferReadError):
+ buf.pull_bytes(2)
- pull_bytes(buf, 2)
self.assertEqual(buf.tell(), 0)
===========changed ref 8===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint64(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint64(), 0x0807060504030201)
- self.assertEqual(pull_uint64(buf), 0x0807060504030201)
self.assertEqual(buf.tell(), 8)
===========changed ref 9===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint32(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint32(), 0x08070605)
- self.assertEqual(pull_uint32(buf), 0x08070605)
self.assertEqual(buf.tell(), 4)
===========changed ref 10===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint16(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint16(), 0x0807)
- self.assertEqual(pull_uint16(buf), 0x0807)
self.assertEqual(buf.tell(), 2)
===========changed ref 11===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint8(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint8(), 0x08)
- self.assertEqual(pull_uint8(buf), 0x08)
self.assertEqual(buf.tell(), 1)
===========changed ref 12===========
# module: tests.test_buffer
class BufferTest(TestCase):
+ def test_data_slice(self):
+ buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.data_slice(1, 3), b"\x07\x06")
+
===========changed ref 13===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_bytes(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_bytes(3), b"\x08\x07\x06")
- self.assertEqual(pull_bytes(buf, 3), b"\x08\x07\x06")
===========changed ref 14===========
# module: aioquic.tls
def pull_group(buf: Buffer) -> Group:
+ return Group(buf.pull_uint16())
- return Group(pull_uint16(buf))
===========changed ref 15===========
# module: aioquic.tls
def pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm:
+ return SignatureAlgorithm(buf.pull_uint16())
- return SignatureAlgorithm(pull_uint16(buf))
===========changed ref 16===========
# module: aioquic.tls
def pull_compression_method(buf: Buffer) -> CompressionMethod:
+ return CompressionMethod(buf.pull_uint8())
- return CompressionMethod(pull_uint8(buf))
===========changed ref 17===========
# module: aioquic.tls
# INTEGERS
def pull_cipher_suite(buf: Buffer) -> CipherSuite:
+ return CipherSuite(buf.pull_uint16())
- return CipherSuite(pull_uint16(buf))
===========changed ref 18===========
# module: aioquic.tls
def pull_key_exchange_mode(buf: Buffer) -> KeyExchangeMode:
+ return KeyExchangeMode(buf.pull_uint8())
- return KeyExchangeMode(pull_uint8(buf))
===========changed ref 19===========
# module: aioquic.buffer
class Buffer:
+ def push_uint8(self, v: int) -> None:
+ """
+ Push an 8-bit unsigned integer.
+ """
+ self._data[self._pos] = v
+ self._pos += 1
+
===========changed ref 20===========
# module: aioquic.tls
def push_key_share(buf: Buffer, value: KeyShareEntry) -> None:
+ buf.push_uint16(value[0])
- push_group(buf, value[0])
push_opaque(buf, 2, value[1])
|
tests.test_buffer/BufferTest.test_push_uint16
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<1>:<add> buf.push_uint16(0x0807)
<del> push_uint16(buf, 0x0807)
|
# module: tests.test_buffer
class BufferTest(TestCase):
def test_push_uint16(self):
<0> buf = Buffer(capacity=2)
<1> push_uint16(buf, 0x0807)
<2> self.assertEqual(buf.data, b"\x08\x07")
<3> self.assertEqual(buf.tell(), 2)
<4>
|
===========unchanged ref 0===========
at: aioquic.buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic.buffer.Buffer
tell() -> int
push_uint64(v: int) -> None
at: unittest.case.TestCase
assertEqual(first: Any, second: Any, msg: Any=...) -> None
===========changed ref 0===========
# module: aioquic.buffer
class Buffer:
+ def push_uint64(self, v: int) -> None:
+ """
+ Push a 64-bit unsigned integer.
+ """
+ pack_into("!Q", self._data, self._pos, v)
+ self._pos += 8
+
===========changed ref 1===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_push_uint8(self):
buf = Buffer(capacity=1)
+ buf.push_uint8(0x08)
- push_uint8(buf, 0x08)
self.assertEqual(buf.data, b"\x08")
self.assertEqual(buf.tell(), 1)
===========changed ref 2===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint64_truncated(self):
buf = Buffer(capacity=7)
with self.assertRaises(BufferReadError):
+ buf.pull_uint64()
- pull_uint64(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 3===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint32_truncated(self):
buf = Buffer(capacity=3)
with self.assertRaises(BufferReadError):
+ buf.pull_uint32()
- pull_uint32(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 4===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_push_bytes_truncated(self):
buf = Buffer(capacity=3)
with self.assertRaises(BufferWriteError):
+ buf.push_bytes(b"\x08\x07\x06\x05")
- push_bytes(buf, b"\x08\x07\x06\x05")
self.assertEqual(buf.tell(), 0)
===========changed ref 5===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint16_truncated(self):
buf = Buffer(capacity=1)
with self.assertRaises(BufferReadError):
+ buf.pull_uint16()
- pull_uint16(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 6===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_push_bytes(self):
buf = Buffer(capacity=3)
+ buf.push_bytes(b"\x08\x07\x06")
- push_bytes(buf, b"\x08\x07\x06")
self.assertEqual(buf.data, b"\x08\x07\x06")
self.assertEqual(buf.tell(), 3)
===========changed ref 7===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint8_truncated(self):
buf = Buffer(capacity=0)
with self.assertRaises(BufferReadError):
+ buf.pull_uint8()
- pull_uint8(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 8===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_bytes_truncated(self):
buf = Buffer(capacity=0)
with self.assertRaises(BufferReadError):
+ buf.pull_bytes(2)
- pull_bytes(buf, 2)
self.assertEqual(buf.tell(), 0)
===========changed ref 9===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint64(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint64(), 0x0807060504030201)
- self.assertEqual(pull_uint64(buf), 0x0807060504030201)
self.assertEqual(buf.tell(), 8)
===========changed ref 10===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint32(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint32(), 0x08070605)
- self.assertEqual(pull_uint32(buf), 0x08070605)
self.assertEqual(buf.tell(), 4)
===========changed ref 11===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint16(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint16(), 0x0807)
- self.assertEqual(pull_uint16(buf), 0x0807)
self.assertEqual(buf.tell(), 2)
===========changed ref 12===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint8(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint8(), 0x08)
- self.assertEqual(pull_uint8(buf), 0x08)
self.assertEqual(buf.tell(), 1)
===========changed ref 13===========
# module: tests.test_buffer
class BufferTest(TestCase):
+ def test_data_slice(self):
+ buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.data_slice(1, 3), b"\x07\x06")
+
===========changed ref 14===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_bytes(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_bytes(3), b"\x08\x07\x06")
- self.assertEqual(pull_bytes(buf, 3), b"\x08\x07\x06")
===========changed ref 15===========
# module: aioquic.tls
def pull_group(buf: Buffer) -> Group:
+ return Group(buf.pull_uint16())
- return Group(pull_uint16(buf))
===========changed ref 16===========
# module: aioquic.tls
def pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm:
+ return SignatureAlgorithm(buf.pull_uint16())
- return SignatureAlgorithm(pull_uint16(buf))
===========changed ref 17===========
# module: aioquic.tls
def pull_compression_method(buf: Buffer) -> CompressionMethod:
+ return CompressionMethod(buf.pull_uint8())
- return CompressionMethod(pull_uint8(buf))
===========changed ref 18===========
# module: aioquic.tls
# INTEGERS
def pull_cipher_suite(buf: Buffer) -> CipherSuite:
+ return CipherSuite(buf.pull_uint16())
- return CipherSuite(pull_uint16(buf))
===========changed ref 19===========
# module: aioquic.tls
def pull_key_exchange_mode(buf: Buffer) -> KeyExchangeMode:
+ return KeyExchangeMode(buf.pull_uint8())
- return KeyExchangeMode(pull_uint8(buf))
===========changed ref 20===========
# module: aioquic.buffer
class Buffer:
+ def push_uint8(self, v: int) -> None:
+ """
+ Push an 8-bit unsigned integer.
+ """
+ self._data[self._pos] = v
+ self._pos += 1
+
|
tests.test_buffer/BufferTest.test_push_uint32
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<1>:<add> buf.push_uint32(0x08070605)
<del> push_uint32(buf, 0x08070605)
|
# module: tests.test_buffer
class BufferTest(TestCase):
def test_push_uint32(self):
<0> buf = Buffer(capacity=4)
<1> push_uint32(buf, 0x08070605)
<2> self.assertEqual(buf.data, b"\x08\x07\x06\x05")
<3> self.assertEqual(buf.tell(), 4)
<4>
|
===========unchanged ref 0===========
at: aioquic.buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic.buffer.Buffer
eof() -> bool
seek(pos: int) -> None
tell() -> int
at: unittest.case.TestCase
assertEqual(first: Any, second: Any, msg: Any=...) -> None
assertFalse(expr: Any, msg: Any=...) -> None
===========changed ref 0===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_push_uint8(self):
buf = Buffer(capacity=1)
+ buf.push_uint8(0x08)
- push_uint8(buf, 0x08)
self.assertEqual(buf.data, b"\x08")
self.assertEqual(buf.tell(), 1)
===========changed ref 1===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_push_uint16(self):
buf = Buffer(capacity=2)
+ buf.push_uint16(0x0807)
- push_uint16(buf, 0x0807)
self.assertEqual(buf.data, b"\x08\x07")
self.assertEqual(buf.tell(), 2)
===========changed ref 2===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint64_truncated(self):
buf = Buffer(capacity=7)
with self.assertRaises(BufferReadError):
+ buf.pull_uint64()
- pull_uint64(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 3===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint32_truncated(self):
buf = Buffer(capacity=3)
with self.assertRaises(BufferReadError):
+ buf.pull_uint32()
- pull_uint32(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 4===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_push_bytes_truncated(self):
buf = Buffer(capacity=3)
with self.assertRaises(BufferWriteError):
+ buf.push_bytes(b"\x08\x07\x06\x05")
- push_bytes(buf, b"\x08\x07\x06\x05")
self.assertEqual(buf.tell(), 0)
===========changed ref 5===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint16_truncated(self):
buf = Buffer(capacity=1)
with self.assertRaises(BufferReadError):
+ buf.pull_uint16()
- pull_uint16(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 6===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_push_bytes(self):
buf = Buffer(capacity=3)
+ buf.push_bytes(b"\x08\x07\x06")
- push_bytes(buf, b"\x08\x07\x06")
self.assertEqual(buf.data, b"\x08\x07\x06")
self.assertEqual(buf.tell(), 3)
===========changed ref 7===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint8_truncated(self):
buf = Buffer(capacity=0)
with self.assertRaises(BufferReadError):
+ buf.pull_uint8()
- pull_uint8(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 8===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_bytes_truncated(self):
buf = Buffer(capacity=0)
with self.assertRaises(BufferReadError):
+ buf.pull_bytes(2)
- pull_bytes(buf, 2)
self.assertEqual(buf.tell(), 0)
===========changed ref 9===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint64(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint64(), 0x0807060504030201)
- self.assertEqual(pull_uint64(buf), 0x0807060504030201)
self.assertEqual(buf.tell(), 8)
===========changed ref 10===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint32(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint32(), 0x08070605)
- self.assertEqual(pull_uint32(buf), 0x08070605)
self.assertEqual(buf.tell(), 4)
===========changed ref 11===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint16(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint16(), 0x0807)
- self.assertEqual(pull_uint16(buf), 0x0807)
self.assertEqual(buf.tell(), 2)
===========changed ref 12===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint8(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint8(), 0x08)
- self.assertEqual(pull_uint8(buf), 0x08)
self.assertEqual(buf.tell(), 1)
===========changed ref 13===========
# module: tests.test_buffer
class BufferTest(TestCase):
+ def test_data_slice(self):
+ buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.data_slice(1, 3), b"\x07\x06")
+
===========changed ref 14===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_bytes(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_bytes(3), b"\x08\x07\x06")
- self.assertEqual(pull_bytes(buf, 3), b"\x08\x07\x06")
===========changed ref 15===========
# module: aioquic.tls
def pull_group(buf: Buffer) -> Group:
+ return Group(buf.pull_uint16())
- return Group(pull_uint16(buf))
===========changed ref 16===========
# module: aioquic.tls
def pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm:
+ return SignatureAlgorithm(buf.pull_uint16())
- return SignatureAlgorithm(pull_uint16(buf))
===========changed ref 17===========
# module: aioquic.tls
def pull_compression_method(buf: Buffer) -> CompressionMethod:
+ return CompressionMethod(buf.pull_uint8())
- return CompressionMethod(pull_uint8(buf))
===========changed ref 18===========
# module: aioquic.tls
# INTEGERS
def pull_cipher_suite(buf: Buffer) -> CipherSuite:
+ return CipherSuite(buf.pull_uint16())
- return CipherSuite(pull_uint16(buf))
===========changed ref 19===========
# module: aioquic.tls
def pull_key_exchange_mode(buf: Buffer) -> KeyExchangeMode:
+ return KeyExchangeMode(buf.pull_uint8())
- return KeyExchangeMode(pull_uint8(buf))
|
tests.test_buffer/BufferTest.test_push_uint64
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<1>:<add> buf.push_uint64(0x0807060504030201)
<del> push_uint64(buf, 0x0807060504030201)
|
# module: tests.test_buffer
class BufferTest(TestCase):
def test_push_uint64(self):
<0> buf = Buffer(capacity=8)
<1> push_uint64(buf, 0x0807060504030201)
<2> self.assertEqual(buf.data, b"\x08\x07\x06\x05\x04\x03\x02\x01")
<3> self.assertEqual(buf.tell(), 8)
<4>
|
===========unchanged ref 0===========
at: aioquic.buffer.Buffer
eof() -> bool
seek(pos: int) -> None
tell() -> int
at: tests.test_buffer.BufferTest.test_seek
buf = Buffer(data=b"01234567")
at: unittest.case.TestCase
assertEqual(first: Any, second: Any, msg: Any=...) -> None
assertTrue(expr: Any, msg: Any=...) -> None
===========changed ref 0===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_push_uint8(self):
buf = Buffer(capacity=1)
+ buf.push_uint8(0x08)
- push_uint8(buf, 0x08)
self.assertEqual(buf.data, b"\x08")
self.assertEqual(buf.tell(), 1)
===========changed ref 1===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_push_uint16(self):
buf = Buffer(capacity=2)
+ buf.push_uint16(0x0807)
- push_uint16(buf, 0x0807)
self.assertEqual(buf.data, b"\x08\x07")
self.assertEqual(buf.tell(), 2)
===========changed ref 2===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_push_uint32(self):
buf = Buffer(capacity=4)
+ buf.push_uint32(0x08070605)
- push_uint32(buf, 0x08070605)
self.assertEqual(buf.data, b"\x08\x07\x06\x05")
self.assertEqual(buf.tell(), 4)
===========changed ref 3===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint64_truncated(self):
buf = Buffer(capacity=7)
with self.assertRaises(BufferReadError):
+ buf.pull_uint64()
- pull_uint64(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 4===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint32_truncated(self):
buf = Buffer(capacity=3)
with self.assertRaises(BufferReadError):
+ buf.pull_uint32()
- pull_uint32(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 5===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_push_bytes_truncated(self):
buf = Buffer(capacity=3)
with self.assertRaises(BufferWriteError):
+ buf.push_bytes(b"\x08\x07\x06\x05")
- push_bytes(buf, b"\x08\x07\x06\x05")
self.assertEqual(buf.tell(), 0)
===========changed ref 6===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint16_truncated(self):
buf = Buffer(capacity=1)
with self.assertRaises(BufferReadError):
+ buf.pull_uint16()
- pull_uint16(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 7===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_push_bytes(self):
buf = Buffer(capacity=3)
+ buf.push_bytes(b"\x08\x07\x06")
- push_bytes(buf, b"\x08\x07\x06")
self.assertEqual(buf.data, b"\x08\x07\x06")
self.assertEqual(buf.tell(), 3)
===========changed ref 8===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint8_truncated(self):
buf = Buffer(capacity=0)
with self.assertRaises(BufferReadError):
+ buf.pull_uint8()
- pull_uint8(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 9===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_bytes_truncated(self):
buf = Buffer(capacity=0)
with self.assertRaises(BufferReadError):
+ buf.pull_bytes(2)
- pull_bytes(buf, 2)
self.assertEqual(buf.tell(), 0)
===========changed ref 10===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint64(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint64(), 0x0807060504030201)
- self.assertEqual(pull_uint64(buf), 0x0807060504030201)
self.assertEqual(buf.tell(), 8)
===========changed ref 11===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint32(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint32(), 0x08070605)
- self.assertEqual(pull_uint32(buf), 0x08070605)
self.assertEqual(buf.tell(), 4)
===========changed ref 12===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint16(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint16(), 0x0807)
- self.assertEqual(pull_uint16(buf), 0x0807)
self.assertEqual(buf.tell(), 2)
===========changed ref 13===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint8(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint8(), 0x08)
- self.assertEqual(pull_uint8(buf), 0x08)
self.assertEqual(buf.tell(), 1)
===========changed ref 14===========
# module: tests.test_buffer
class BufferTest(TestCase):
+ def test_data_slice(self):
+ buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.data_slice(1, 3), b"\x07\x06")
+
===========changed ref 15===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_bytes(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_bytes(3), b"\x08\x07\x06")
- self.assertEqual(pull_bytes(buf, 3), b"\x08\x07\x06")
===========changed ref 16===========
# module: aioquic.tls
def pull_group(buf: Buffer) -> Group:
+ return Group(buf.pull_uint16())
- return Group(pull_uint16(buf))
===========changed ref 17===========
# module: aioquic.tls
def pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm:
+ return SignatureAlgorithm(buf.pull_uint16())
- return SignatureAlgorithm(pull_uint16(buf))
===========changed ref 18===========
# module: aioquic.tls
def pull_compression_method(buf: Buffer) -> CompressionMethod:
+ return CompressionMethod(buf.pull_uint8())
- return CompressionMethod(pull_uint8(buf))
|
tests.test_buffer/UintVarTest.roundtrip
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<1>:<add> self.assertEqual(buf.pull_uint_var(), value)
<del> self.assertEqual(pull_uint_var(buf), value)
<5>:<add> buf.push_uint_var(value)
<del> push_uint_var(buf, value)
|
# module: tests.test_buffer
class UintVarTest(TestCase):
def roundtrip(self, data, value):
<0> buf = Buffer(data=data)
<1> self.assertEqual(pull_uint_var(buf), value)
<2> self.assertEqual(buf.tell(), len(data))
<3>
<4> buf = Buffer(capacity=8)
<5> push_uint_var(buf, value)
<6> self.assertEqual(buf.data, data)
<7>
|
===========unchanged ref 0===========
at: tests.test_buffer.UintVarTest
roundtrip(data, value)
===========changed ref 0===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_push_uint8(self):
buf = Buffer(capacity=1)
+ buf.push_uint8(0x08)
- push_uint8(buf, 0x08)
self.assertEqual(buf.data, b"\x08")
self.assertEqual(buf.tell(), 1)
===========changed ref 1===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_push_uint16(self):
buf = Buffer(capacity=2)
+ buf.push_uint16(0x0807)
- push_uint16(buf, 0x0807)
self.assertEqual(buf.data, b"\x08\x07")
self.assertEqual(buf.tell(), 2)
===========changed ref 2===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_push_uint32(self):
buf = Buffer(capacity=4)
+ buf.push_uint32(0x08070605)
- push_uint32(buf, 0x08070605)
self.assertEqual(buf.data, b"\x08\x07\x06\x05")
self.assertEqual(buf.tell(), 4)
===========changed ref 3===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint64_truncated(self):
buf = Buffer(capacity=7)
with self.assertRaises(BufferReadError):
+ buf.pull_uint64()
- pull_uint64(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 4===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint32_truncated(self):
buf = Buffer(capacity=3)
with self.assertRaises(BufferReadError):
+ buf.pull_uint32()
- pull_uint32(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 5===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_push_uint64(self):
buf = Buffer(capacity=8)
+ buf.push_uint64(0x0807060504030201)
- push_uint64(buf, 0x0807060504030201)
self.assertEqual(buf.data, b"\x08\x07\x06\x05\x04\x03\x02\x01")
self.assertEqual(buf.tell(), 8)
===========changed ref 6===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_push_bytes_truncated(self):
buf = Buffer(capacity=3)
with self.assertRaises(BufferWriteError):
+ buf.push_bytes(b"\x08\x07\x06\x05")
- push_bytes(buf, b"\x08\x07\x06\x05")
self.assertEqual(buf.tell(), 0)
===========changed ref 7===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint16_truncated(self):
buf = Buffer(capacity=1)
with self.assertRaises(BufferReadError):
+ buf.pull_uint16()
- pull_uint16(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 8===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_push_bytes(self):
buf = Buffer(capacity=3)
+ buf.push_bytes(b"\x08\x07\x06")
- push_bytes(buf, b"\x08\x07\x06")
self.assertEqual(buf.data, b"\x08\x07\x06")
self.assertEqual(buf.tell(), 3)
===========changed ref 9===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint8_truncated(self):
buf = Buffer(capacity=0)
with self.assertRaises(BufferReadError):
+ buf.pull_uint8()
- pull_uint8(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 10===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_bytes_truncated(self):
buf = Buffer(capacity=0)
with self.assertRaises(BufferReadError):
+ buf.pull_bytes(2)
- pull_bytes(buf, 2)
self.assertEqual(buf.tell(), 0)
===========changed ref 11===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint64(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint64(), 0x0807060504030201)
- self.assertEqual(pull_uint64(buf), 0x0807060504030201)
self.assertEqual(buf.tell(), 8)
===========changed ref 12===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint32(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint32(), 0x08070605)
- self.assertEqual(pull_uint32(buf), 0x08070605)
self.assertEqual(buf.tell(), 4)
===========changed ref 13===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint16(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint16(), 0x0807)
- self.assertEqual(pull_uint16(buf), 0x0807)
self.assertEqual(buf.tell(), 2)
===========changed ref 14===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint8(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint8(), 0x08)
- self.assertEqual(pull_uint8(buf), 0x08)
self.assertEqual(buf.tell(), 1)
===========changed ref 15===========
# module: tests.test_buffer
class BufferTest(TestCase):
+ def test_data_slice(self):
+ buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.data_slice(1, 3), b"\x07\x06")
+
===========changed ref 16===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_bytes(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_bytes(3), b"\x08\x07\x06")
- self.assertEqual(pull_bytes(buf, 3), b"\x08\x07\x06")
===========changed ref 17===========
# module: aioquic.tls
def pull_group(buf: Buffer) -> Group:
+ return Group(buf.pull_uint16())
- return Group(pull_uint16(buf))
===========changed ref 18===========
# module: aioquic.tls
def pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm:
+ return SignatureAlgorithm(buf.pull_uint16())
- return SignatureAlgorithm(pull_uint16(buf))
===========changed ref 19===========
# module: aioquic.tls
def pull_compression_method(buf: Buffer) -> CompressionMethod:
+ return CompressionMethod(buf.pull_uint8())
- return CompressionMethod(pull_uint8(buf))
|
tests.test_buffer/UintVarTest.test_pull_uint_var_truncated
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<2>:<add> buf.pull_uint_var()
<del> pull_uint_var(buf)
<6>:<add> buf.pull_uint_var()
<del> pull_uint_var(buf)
|
# module: tests.test_buffer
class UintVarTest(TestCase):
def test_pull_uint_var_truncated(self):
<0> buf = Buffer(capacity=0)
<1> with self.assertRaises(BufferReadError):
<2> pull_uint_var(buf)
<3>
<4> buf = Buffer(data=b"\xff")
<5> with self.assertRaises(BufferReadError):
<6> pull_uint_var(buf)
<7>
|
===========unchanged ref 0===========
at: aioquic.buffer
size_uint_var(value: int) -> int
at: unittest.case.TestCase
assertEqual(first: Any, second: Any, msg: Any=...) -> None
at: unittest.case._AssertRaisesContext.__exit__
self.exception = exc_value.with_traceback(None)
===========changed ref 0===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_push_uint8(self):
buf = Buffer(capacity=1)
+ buf.push_uint8(0x08)
- push_uint8(buf, 0x08)
self.assertEqual(buf.data, b"\x08")
self.assertEqual(buf.tell(), 1)
===========changed ref 1===========
# module: tests.test_buffer
class UintVarTest(TestCase):
def roundtrip(self, data, value):
buf = Buffer(data=data)
+ self.assertEqual(buf.pull_uint_var(), value)
- self.assertEqual(pull_uint_var(buf), value)
self.assertEqual(buf.tell(), len(data))
buf = Buffer(capacity=8)
+ buf.push_uint_var(value)
- push_uint_var(buf, value)
self.assertEqual(buf.data, data)
===========changed ref 2===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_push_uint16(self):
buf = Buffer(capacity=2)
+ buf.push_uint16(0x0807)
- push_uint16(buf, 0x0807)
self.assertEqual(buf.data, b"\x08\x07")
self.assertEqual(buf.tell(), 2)
===========changed ref 3===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_push_uint32(self):
buf = Buffer(capacity=4)
+ buf.push_uint32(0x08070605)
- push_uint32(buf, 0x08070605)
self.assertEqual(buf.data, b"\x08\x07\x06\x05")
self.assertEqual(buf.tell(), 4)
===========changed ref 4===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint64_truncated(self):
buf = Buffer(capacity=7)
with self.assertRaises(BufferReadError):
+ buf.pull_uint64()
- pull_uint64(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 5===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint32_truncated(self):
buf = Buffer(capacity=3)
with self.assertRaises(BufferReadError):
+ buf.pull_uint32()
- pull_uint32(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 6===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_push_uint64(self):
buf = Buffer(capacity=8)
+ buf.push_uint64(0x0807060504030201)
- push_uint64(buf, 0x0807060504030201)
self.assertEqual(buf.data, b"\x08\x07\x06\x05\x04\x03\x02\x01")
self.assertEqual(buf.tell(), 8)
===========changed ref 7===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_push_bytes_truncated(self):
buf = Buffer(capacity=3)
with self.assertRaises(BufferWriteError):
+ buf.push_bytes(b"\x08\x07\x06\x05")
- push_bytes(buf, b"\x08\x07\x06\x05")
self.assertEqual(buf.tell(), 0)
===========changed ref 8===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint16_truncated(self):
buf = Buffer(capacity=1)
with self.assertRaises(BufferReadError):
+ buf.pull_uint16()
- pull_uint16(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 9===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_push_bytes(self):
buf = Buffer(capacity=3)
+ buf.push_bytes(b"\x08\x07\x06")
- push_bytes(buf, b"\x08\x07\x06")
self.assertEqual(buf.data, b"\x08\x07\x06")
self.assertEqual(buf.tell(), 3)
===========changed ref 10===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint8_truncated(self):
buf = Buffer(capacity=0)
with self.assertRaises(BufferReadError):
+ buf.pull_uint8()
- pull_uint8(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 11===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_bytes_truncated(self):
buf = Buffer(capacity=0)
with self.assertRaises(BufferReadError):
+ buf.pull_bytes(2)
- pull_bytes(buf, 2)
self.assertEqual(buf.tell(), 0)
===========changed ref 12===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint64(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint64(), 0x0807060504030201)
- self.assertEqual(pull_uint64(buf), 0x0807060504030201)
self.assertEqual(buf.tell(), 8)
===========changed ref 13===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint32(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint32(), 0x08070605)
- self.assertEqual(pull_uint32(buf), 0x08070605)
self.assertEqual(buf.tell(), 4)
===========changed ref 14===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint16(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint16(), 0x0807)
- self.assertEqual(pull_uint16(buf), 0x0807)
self.assertEqual(buf.tell(), 2)
===========changed ref 15===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint8(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint8(), 0x08)
- self.assertEqual(pull_uint8(buf), 0x08)
self.assertEqual(buf.tell(), 1)
===========changed ref 16===========
# module: tests.test_buffer
class BufferTest(TestCase):
+ def test_data_slice(self):
+ buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.data_slice(1, 3), b"\x07\x06")
+
|
tests.test_buffer/UintVarTest.test_push_uint_var_too_big
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<2>:<add> buf.push_uint_var(4611686018427387904)
<del> push_uint_var(buf, 4611686018427387904)
|
# module: tests.test_buffer
class UintVarTest(TestCase):
def test_push_uint_var_too_big(self):
<0> buf = Buffer(capacity=8)
<1> with self.assertRaises(ValueError) as cm:
<2> push_uint_var(buf, 4611686018427387904)
<3> self.assertEqual(
<4> str(cm.exception), "Integer is too big for a variable-length integer"
<5> )
<6>
|
===========unchanged ref 0===========
at: aioquic.buffer
size_uint_var(value: int) -> int
at: unittest.case.TestCase
assertEqual(first: Any, second: Any, msg: Any=...) -> None
assertRaises(expected_exception: Union[Type[_E], Tuple[Type[_E], ...]], msg: Any=...) -> _AssertRaisesContext[_E]
assertRaises(expected_exception: Union[Type[BaseException], Tuple[Type[BaseException], ...]], callable: Callable[..., Any], *args: Any, **kwargs: Any) -> None
at: unittest.case._AssertRaisesContext.__exit__
self.exception = exc_value.with_traceback(None)
===========changed ref 0===========
# module: tests.test_buffer
class UintVarTest(TestCase):
def test_pull_uint_var_truncated(self):
buf = Buffer(capacity=0)
with self.assertRaises(BufferReadError):
+ buf.pull_uint_var()
- pull_uint_var(buf)
buf = Buffer(data=b"\xff")
with self.assertRaises(BufferReadError):
+ buf.pull_uint_var()
- pull_uint_var(buf)
===========changed ref 1===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_push_uint8(self):
buf = Buffer(capacity=1)
+ buf.push_uint8(0x08)
- push_uint8(buf, 0x08)
self.assertEqual(buf.data, b"\x08")
self.assertEqual(buf.tell(), 1)
===========changed ref 2===========
# module: tests.test_buffer
class UintVarTest(TestCase):
def roundtrip(self, data, value):
buf = Buffer(data=data)
+ self.assertEqual(buf.pull_uint_var(), value)
- self.assertEqual(pull_uint_var(buf), value)
self.assertEqual(buf.tell(), len(data))
buf = Buffer(capacity=8)
+ buf.push_uint_var(value)
- push_uint_var(buf, value)
self.assertEqual(buf.data, data)
===========changed ref 3===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_push_uint16(self):
buf = Buffer(capacity=2)
+ buf.push_uint16(0x0807)
- push_uint16(buf, 0x0807)
self.assertEqual(buf.data, b"\x08\x07")
self.assertEqual(buf.tell(), 2)
===========changed ref 4===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_push_uint32(self):
buf = Buffer(capacity=4)
+ buf.push_uint32(0x08070605)
- push_uint32(buf, 0x08070605)
self.assertEqual(buf.data, b"\x08\x07\x06\x05")
self.assertEqual(buf.tell(), 4)
===========changed ref 5===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint64_truncated(self):
buf = Buffer(capacity=7)
with self.assertRaises(BufferReadError):
+ buf.pull_uint64()
- pull_uint64(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 6===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint32_truncated(self):
buf = Buffer(capacity=3)
with self.assertRaises(BufferReadError):
+ buf.pull_uint32()
- pull_uint32(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 7===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_push_uint64(self):
buf = Buffer(capacity=8)
+ buf.push_uint64(0x0807060504030201)
- push_uint64(buf, 0x0807060504030201)
self.assertEqual(buf.data, b"\x08\x07\x06\x05\x04\x03\x02\x01")
self.assertEqual(buf.tell(), 8)
===========changed ref 8===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_push_bytes_truncated(self):
buf = Buffer(capacity=3)
with self.assertRaises(BufferWriteError):
+ buf.push_bytes(b"\x08\x07\x06\x05")
- push_bytes(buf, b"\x08\x07\x06\x05")
self.assertEqual(buf.tell(), 0)
===========changed ref 9===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint16_truncated(self):
buf = Buffer(capacity=1)
with self.assertRaises(BufferReadError):
+ buf.pull_uint16()
- pull_uint16(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 10===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_push_bytes(self):
buf = Buffer(capacity=3)
+ buf.push_bytes(b"\x08\x07\x06")
- push_bytes(buf, b"\x08\x07\x06")
self.assertEqual(buf.data, b"\x08\x07\x06")
self.assertEqual(buf.tell(), 3)
===========changed ref 11===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint8_truncated(self):
buf = Buffer(capacity=0)
with self.assertRaises(BufferReadError):
+ buf.pull_uint8()
- pull_uint8(buf)
self.assertEqual(buf.tell(), 0)
===========changed ref 12===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_bytes_truncated(self):
buf = Buffer(capacity=0)
with self.assertRaises(BufferReadError):
+ buf.pull_bytes(2)
- pull_bytes(buf, 2)
self.assertEqual(buf.tell(), 0)
===========changed ref 13===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint64(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint64(), 0x0807060504030201)
- self.assertEqual(pull_uint64(buf), 0x0807060504030201)
self.assertEqual(buf.tell(), 8)
===========changed ref 14===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint32(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint32(), 0x08070605)
- self.assertEqual(pull_uint32(buf), 0x08070605)
self.assertEqual(buf.tell(), 4)
===========changed ref 15===========
# module: tests.test_buffer
class BufferTest(TestCase):
def test_pull_uint16(self):
buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
+ self.assertEqual(buf.pull_uint16(), 0x0807)
- self.assertEqual(pull_uint16(buf), 0x0807)
self.assertEqual(buf.tell(), 2)
|
tests.test_tls/ContextTest.test_session_ticket
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
# module: tests.test_tls
class ContextTest(TestCase):
def test_session_ticket(self):
<0> client_tickets = []
<1> server_tickets = []
<2>
<3> def client_new_ticket(ticket):
<4> client_tickets.append(ticket)
<5>
<6> def server_get_ticket(label):
<7> for t in server_tickets:
<8> if t.ticket == label:
<9> return t
<10> return None
<11>
<12> def server_new_ticket(ticket):
<13> server_tickets.append(ticket)
<14>
<15> def first_handshake():
<16> client = self.create_client()
<17> client.new_session_ticket_cb = client_new_ticket
<18>
<19> server = self.create_server()
<20> server.new_session_ticket_cb = server_new_ticket
<21>
<22> self._handshake(client, server)
<23>
<24> # check session resumption was not used
<25> self.assertFalse(client.session_resumed)
<26> self.assertFalse(server.session_resumed)
<27>
<28> # check tickets match
<29> self.assertEqual(len(client_tickets), 1)
<30> self.assertEqual(len(server_tickets), 1)
<31> self.assertEqual(client_tickets[0].ticket, server_tickets[0].ticket)
<32> self.assertEqual(
<33> client_tickets[0].resumption_secret, server_tickets[0].resumption_secret
<34> )
<35>
<36> def second_handshake():
<37> client = self.create_client()
<38> client.session_ticket = client_tickets[0]
<39>
<40> server = self.create_server()
<41> server.get_session_ticket_cb = server_get_ticket
<42>
<43> # send client hello with pre_shared_key
<44> client_buf = create_buffers()
<45> client.handle_message(b"", client_buf)
<46> self.assertEqual(client.state, State.CLIENT_EXPECT</s>
|
===========below chunk 0===========
# module: tests.test_tls
class ContextTest(TestCase):
def test_session_ticket(self):
# offset: 1
server_input = merge_buffers(client_buf)
self.assertEqual(len(server_input), 383)
reset_buffers(client_buf)
# handle client hello
# send server hello, encrypted extensions, finished
server_buf = create_buffers()
server.handle_message(server_input, server_buf)
self.assertEqual(server.state, State.SERVER_EXPECT_FINISHED)
client_input = merge_buffers(server_buf)
self.assertEqual(len(client_input), 307)
reset_buffers(server_buf)
# handle server hello, encrypted extensions, certificate, certificate verify, finished
# send finished
client.handle_message(client_input, client_buf)
self.assertEqual(client.state, State.CLIENT_POST_HANDSHAKE)
server_input = merge_buffers(client_buf)
self.assertEqual(len(server_input), 52)
reset_buffers(client_buf)
# handle finished
# send new_session_ticket
server.handle_message(server_input, server_buf)
self.assertEqual(server.state, State.SERVER_POST_HANDSHAKE)
client_input = merge_buffers(server_buf)
self.assertEqual(len(client_input), 0)
reset_buffers(server_buf)
# check keys match
self.assertEqual(client._dec_key, server._enc_key)
self.assertEqual(client._enc_key, server._dec_key)
# check session resumption was used
self.assertTrue(client.session_resumed)
self.assertTrue(server.session_resumed)
def second_handshake_bad_binder():
client = self.create_client()
client.session_ticket = client_tickets[0]
server = self.create_server()
server.get_session_ticket</s>
===========below chunk 1===========
# module: tests.test_tls
class ContextTest(TestCase):
def test_session_ticket(self):
# offset: 2
<s>_ticket = client_tickets[0]
server = self.create_server()
server.get_session_ticket_cb = server_get_ticket
# send client hello with pre_shared_key
client_buf = create_buffers()
client.handle_message(b"", client_buf)
self.assertEqual(client.state, State.CLIENT_EXPECT_SERVER_HELLO)
server_input = merge_buffers(client_buf)
self.assertEqual(len(server_input), 383)
reset_buffers(client_buf)
# tamper with binder
server_input = server_input[:-4] + bytes(4)
# handle client hello
# send server hello, encrypted extensions, finished
server_buf = create_buffers()
with self.assertRaises(tls.AlertHandshakeFailure) as cm:
server.handle_message(server_input, server_buf)
self.assertEqual(str(cm.exception), "PSK validation failed")
def second_handshake_bad_pre_shared_key():
client = self.create_client()
client.session_ticket = client_tickets[0]
server = self.create_server()
server.get_session_ticket_cb = server_get_ticket
# send client hello with pre_shared_key
client_buf = create_buffers()
client.handle_message(b"", client_buf)
self.assertEqual(client.state, State.CLIENT_EXPECT_SERVER_HELLO)
server_input = merge_buffers(client_buf)
self.assertEqual(len(server_input), 383)
reset_buffers(client_buf)
# handle client hello
# send server hello, encrypted extensions, finished
server_buf = create</s>
===========below chunk 2===========
# module: tests.test_tls
class ContextTest(TestCase):
def test_session_ticket(self):
# offset: 3
<s>()
server.handle_message(server_input, server_buf)
self.assertEqual(server.state, State.SERVER_EXPECT_FINISHED)
# tamper with pre_share_key index
buf = server_buf[tls.Epoch.INITIAL]
buf.seek(buf.tell() - 1)
push_uint8(buf, 1)
client_input = merge_buffers(server_buf)
self.assertEqual(len(client_input), 307)
reset_buffers(server_buf)
# handle server hello and bomb
with self.assertRaises(tls.AlertIllegalParameter):
client.handle_message(client_input, client_buf)
first_handshake()
second_handshake()
second_handshake_bad_binder()
second_handshake_bad_pre_shared_key()
===========unchanged ref 0===========
at: aioquic.buffer.Buffer
seek(pos: int) -> None
tell() -> int
push_uint8(v: int) -> None
at: aioquic.tls
AlertHandshakeFailure(*args: object)
AlertIllegalParameter(*args: object)
Epoch()
State()
at: aioquic.tls.Context
handle_message(input_data: bytes, output_buf: Dict[Epoch, Buffer]) -> None
at: aioquic.tls.Context.__init__
self.session_ticket: Optional[SessionTicket] = None
self.get_session_ticket_cb: Optional[SessionTicketFetcher] = None
self.new_session_ticket_cb: Optional[SessionTicketHandler] = None
self.state = State.CLIENT_HANDSHAKE_START
self.state = State.SERVER_EXPECT_CLIENT_HELLO
at: aioquic.tls.Context._set_state
self.state = state
at: tests.test_tls
create_buffers()
merge_buffers(buffers)
reset_buffers(buffers)
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
assertTrue(expr: Any, msg: Any=...) -> None
assertFalse(expr: Any, msg: Any=...) -> None
===========unchanged ref 1===========
assertRaises(expected_exception: Union[Type[_E], Tuple[Type[_E], ...]], msg: Any=...) -> _AssertRaisesContext[_E]
assertRaises(expected_exception: Union[Type[BaseException], Tuple[Type[BaseException], ...]], callable: Callable[..., Any], *args: Any, **kwargs: Any) -> None
at: unittest.case._AssertRaisesContext.__exit__
self.exception = exc_value.with_traceback(None)
===========changed ref 0===========
# module: aioquic.buffer
class Buffer:
+ def push_uint8(self, v: int) -> None:
+ """
+ Push an 8-bit unsigned integer.
+ """
+ self._data[self._pos] = v
+ self._pos += 1
+
===========changed ref 1===========
# module: aioquic.tls
def pull_group(buf: Buffer) -> Group:
+ return Group(buf.pull_uint16())
- return Group(pull_uint16(buf))
===========changed ref 2===========
# module: aioquic.tls
def pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm:
+ return SignatureAlgorithm(buf.pull_uint16())
- return SignatureAlgorithm(pull_uint16(buf))
|
|
tests.test_crypto/CryptoTest.test_key_update
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<5>:<add> buf.push_uint8(PACKET_FIXED_BIT | key_phase << 2 | 1)
<del> push_uint8(buf, PACKET_FIXED_BIT | key_phase << 2 | 1)
<6>:<add> buf.push_bytes(binascii.unhexlify("8394c8f03e515708"))
<del> push_bytes(buf, binascii.unhexlify("8394c8f03e515708"))
<7>:<add> buf.push_uint16(packet_number)
<del> push_uint16(buf, packet_number)
|
# module: tests.test_crypto
class CryptoTest(TestCase):
def test_key_update(self):
<0> pair1 = self.create_crypto(is_client=True)
<1> pair2 = self.create_crypto(is_client=False)
<2>
<3> def create_packet(key_phase, packet_number=0):
<4> buf = Buffer(capacity=100)
<5> push_uint8(buf, PACKET_FIXED_BIT | key_phase << 2 | 1)
<6> push_bytes(buf, binascii.unhexlify("8394c8f03e515708"))
<7> push_uint16(buf, packet_number)
<8> return buf.data, b"\x00\x01\x02\x03"
<9>
<10> def send(sender, receiver):
<11> plain_header, plain_payload = create_packet(key_phase=sender.key_phase)
<12> encrypted = sender.encrypt_packet(plain_header, plain_payload)
<13> recov_header, recov_payload, _ = receiver.decrypt_packet(
<14> encrypted, len(plain_header) - 2, 0
<15> )
<16> self.assertEqual(recov_header, plain_header)
<17> self.assertEqual(recov_payload, plain_payload)
<18>
<19> # roundtrip
<20> send(pair1, pair2)
<21> send(pair2, pair1)
<22> self.assertEqual(pair1.key_phase, 0)
<23> self.assertEqual(pair2.key_phase, 0)
<24>
<25> # pair 1 key update
<26> pair1.update_key()
<27>
<28> # roundtrip
<29> send(pair1, pair2)
<30> send(pair2, pair1)
<31> self.assertEqual(pair1.key_phase, 1)
<32> self.assertEqual(pair2.key_phase, 1)
<33>
<34> # pair 2 key update
<35> pair2.update_key()
<36>
<37> # roundtrip
<38> send(pair2, pair1)
<39> send(pair1, pair2)</s>
|
===========below chunk 0===========
# module: tests.test_crypto
class CryptoTest(TestCase):
def test_key_update(self):
# offset: 1
self.assertEqual(pair2.key_phase, 0)
# pair 1 key - update, but not next to send
pair1.update_key()
# roundtrip
send(pair2, pair1)
send(pair1, pair2)
self.assertEqual(pair1.key_phase, 1)
self.assertEqual(pair2.key_phase, 1)
===========unchanged ref 0===========
at: aioquic.buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic.buffer.Buffer
push_bytes(v: bytes) -> None
push_uint8(v: int) -> None
push_uint16(v: int) -> None
at: aioquic.crypto.CryptoPair
encrypt_packet(plain_header: bytes, plain_payload: bytes) -> bytes
at: aioquic.packet
PACKET_FIXED_BIT = 0x40
at: binascii
unhexlify(hexstr: _Ascii, /) -> bytes
at: tests.test_crypto.CryptoTest
create_crypto(is_client)
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.buffer
class Buffer:
+ def push_uint8(self, v: int) -> None:
+ """
+ Push an 8-bit unsigned integer.
+ """
+ self._data[self._pos] = v
+ self._pos += 1
+
===========changed ref 1===========
# module: aioquic.buffer
class Buffer:
+ def push_uint16(self, v: int) -> None:
+ """
+ Push a 16-bit unsigned integer.
+ """
+ pack_into("!H", self._data, self._pos, v)
+ self._pos += 2
+
===========changed ref 2===========
# module: aioquic.buffer
class Buffer:
+ def push_bytes(self, v: bytes) -> None:
+ """
+ Push bytes.
+ """
+ end = self._pos + len(v)
+ if end > self._length:
+ raise BufferWriteError
+ self._data[self._pos : end] = v
+ self._pos = end
+
===========changed ref 3===========
# module: aioquic.tls
def pull_group(buf: Buffer) -> Group:
+ return Group(buf.pull_uint16())
- return Group(pull_uint16(buf))
===========changed ref 4===========
# module: aioquic.tls
def pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm:
+ return SignatureAlgorithm(buf.pull_uint16())
- return SignatureAlgorithm(pull_uint16(buf))
===========changed ref 5===========
# module: aioquic.tls
def pull_compression_method(buf: Buffer) -> CompressionMethod:
+ return CompressionMethod(buf.pull_uint8())
- return CompressionMethod(pull_uint8(buf))
===========changed ref 6===========
# module: aioquic.tls
# INTEGERS
def pull_cipher_suite(buf: Buffer) -> CipherSuite:
+ return CipherSuite(buf.pull_uint16())
- return CipherSuite(pull_uint16(buf))
===========changed ref 7===========
# module: aioquic.tls
def pull_key_exchange_mode(buf: Buffer) -> KeyExchangeMode:
+ return KeyExchangeMode(buf.pull_uint8())
- return KeyExchangeMode(pull_uint8(buf))
===========changed ref 8===========
# module: aioquic.tls
def push_key_share(buf: Buffer, value: KeyShareEntry) -> None:
+ buf.push_uint16(value[0])
- push_group(buf, value[0])
push_opaque(buf, 2, value[1])
===========changed ref 9===========
# module: aioquic.tls
@contextmanager
def push_extension(buf: Buffer, extension_type: int) -> Generator:
+ buf.push_uint16(extension_type)
- push_uint16(buf, extension_type)
with push_block(buf, 2):
yield
===========changed ref 10===========
# module: aioquic.buffer
- def push_uint8(buf: Buffer, v: int) -> None:
- """
- Push an 8-bit unsigned integer.
- """
- buf._data[buf._pos] = v
- buf._pos += 1
-
===========changed ref 11===========
# module: aioquic.tls
def push_psk_identity(buf: Buffer, entry: PskIdentity) -> None:
push_opaque(buf, 2, entry[0])
+ buf.push_uint32(entry[1])
- push_uint32(buf, entry[1])
===========changed ref 12===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_data_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a DATA_BLOCKED frame.
"""
+ buf.pull_uint_var() # limit
- pull_uint_var(buf) # limit
===========changed ref 13===========
# module: aioquic.buffer
class Buffer:
+ def push_uint64(self, v: int) -> None:
+ """
+ Push a 64-bit unsigned integer.
+ """
+ pack_into("!Q", self._data, self._pos, v)
+ self._pos += 8
+
===========changed ref 14===========
# module: aioquic.buffer
class Buffer:
+ def push_uint32(self, v: int) -> None:
+ """
+ Push a 32-bit unsigned integer.
+ """
+ pack_into("!L", self._data, self._pos, v)
+ self._pos += 4
+
===========changed ref 15===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_streams_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a STREAMS_BLOCKED frame.
"""
+ buf.pull_uint_var() # limit
- pull_uint_var(buf) # limit
===========changed ref 16===========
# module: aioquic.tls
def push_list(
+ buf: Buffer, capacity: int, func: Callable[[T], None], values: Sequence[T]
- buf: Buffer, capacity: int, func: Callable[[Buffer, T], None], values: Sequence[T]
) -> None:
"""
Push a list of items.
"""
with push_block(buf, capacity):
for value in values:
+ func(value)
- func(buf, value)
===========changed ref 17===========
# module: aioquic.packet
def pull_new_token_frame(buf: Buffer) -> bytes:
+ length = buf.pull_uint_var()
- length = pull_uint_var(buf)
+ return buf.pull_bytes(length)
- return pull_bytes(buf, length)
===========changed ref 18===========
# module: aioquic.tls
def push_finished(buf: Buffer, finished: Finished) -> None:
+ buf.push_uint8(HandshakeType.FINISHED)
- push_uint8(buf, HandshakeType.FINISHED)
push_opaque(buf, 3, finished.verify_data)
===========changed ref 19===========
# module: aioquic.buffer
- def push_uint64(buf: Buffer, v: int) -> None:
- """
- Push a 64-bit unsigned integer.
- """
- pack_into("!Q", buf._data, buf._pos, v)
- buf._pos += 8
-
===========changed ref 20===========
# module: aioquic.buffer
- def push_uint32(buf: Buffer, v: int) -> None:
- """
- Push a 32-bit unsigned integer.
- """
- pack_into("!L", buf._data, buf._pos, v)
- buf._pos += 4
-
|
tests.test_connection/encode_uint_var
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<1>:<add> buf.push_uint_var(v)
<del> push_uint_var(buf, v)
|
# module: tests.test_connection
def encode_uint_var(v):
<0> buf = Buffer(capacity=8)
<1> push_uint_var(buf, v)
<2> return buf.data
<3>
|
===========unchanged ref 0===========
at: aioquic.buffer
Buffer(capacity: Optional[int]=0, data: Optional[bytes]=None)
at: aioquic.buffer.Buffer
push_uint_var(value: int) -> None
===========changed ref 0===========
# module: aioquic.buffer
class Buffer:
+ def push_uint_var(self, value: int) -> None:
+ """
+ Push a QUIC variable-length unsigned integer.
+ """
+ if value <= 0x3F:
+ self._data[self._pos] = value
+ self._pos += 1
+ elif value <= 0x3FFF:
+ pack_into("!H", self._data, self._pos, value | 0x4000)
+ self._pos += 2
+ elif value <= 0x3FFFFFFF:
+ pack_into("!L", self._data, self._pos, value | 0x80000000)
+ self._pos += 4
+ elif value <= 0x3FFFFFFFFFFFFFFF:
+ pack_into("!Q", self._data, self._pos, value | 0xC000000000000000)
+ self._pos += 8
+ else:
+ raise ValueError("Integer is too big for a variable-length integer")
+
===========changed ref 1===========
# module: aioquic.tls
def pull_group(buf: Buffer) -> Group:
+ return Group(buf.pull_uint16())
- return Group(pull_uint16(buf))
===========changed ref 2===========
# module: aioquic.tls
def pull_signature_algorithm(buf: Buffer) -> SignatureAlgorithm:
+ return SignatureAlgorithm(buf.pull_uint16())
- return SignatureAlgorithm(pull_uint16(buf))
===========changed ref 3===========
# module: aioquic.tls
def pull_compression_method(buf: Buffer) -> CompressionMethod:
+ return CompressionMethod(buf.pull_uint8())
- return CompressionMethod(pull_uint8(buf))
===========changed ref 4===========
# module: aioquic.tls
# INTEGERS
def pull_cipher_suite(buf: Buffer) -> CipherSuite:
+ return CipherSuite(buf.pull_uint16())
- return CipherSuite(pull_uint16(buf))
===========changed ref 5===========
# module: aioquic.tls
def pull_key_exchange_mode(buf: Buffer) -> KeyExchangeMode:
+ return KeyExchangeMode(buf.pull_uint8())
- return KeyExchangeMode(pull_uint8(buf))
===========changed ref 6===========
# module: aioquic.buffer
class Buffer:
+ def push_uint8(self, v: int) -> None:
+ """
+ Push an 8-bit unsigned integer.
+ """
+ self._data[self._pos] = v
+ self._pos += 1
+
===========changed ref 7===========
# module: aioquic.tls
def push_key_share(buf: Buffer, value: KeyShareEntry) -> None:
+ buf.push_uint16(value[0])
- push_group(buf, value[0])
push_opaque(buf, 2, value[1])
===========changed ref 8===========
# module: aioquic.tls
@contextmanager
def push_extension(buf: Buffer, extension_type: int) -> Generator:
+ buf.push_uint16(extension_type)
- push_uint16(buf, extension_type)
with push_block(buf, 2):
yield
===========changed ref 9===========
# module: aioquic.buffer
- def push_uint8(buf: Buffer, v: int) -> None:
- """
- Push an 8-bit unsigned integer.
- """
- buf._data[buf._pos] = v
- buf._pos += 1
-
===========changed ref 10===========
# module: aioquic.tls
def push_psk_identity(buf: Buffer, entry: PskIdentity) -> None:
push_opaque(buf, 2, entry[0])
+ buf.push_uint32(entry[1])
- push_uint32(buf, entry[1])
===========changed ref 11===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_data_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a DATA_BLOCKED frame.
"""
+ buf.pull_uint_var() # limit
- pull_uint_var(buf) # limit
===========changed ref 12===========
# module: aioquic.buffer
class Buffer:
+ def push_uint64(self, v: int) -> None:
+ """
+ Push a 64-bit unsigned integer.
+ """
+ pack_into("!Q", self._data, self._pos, v)
+ self._pos += 8
+
===========changed ref 13===========
# module: aioquic.buffer
class Buffer:
+ def push_uint32(self, v: int) -> None:
+ """
+ Push a 32-bit unsigned integer.
+ """
+ pack_into("!L", self._data, self._pos, v)
+ self._pos += 4
+
===========changed ref 14===========
# module: aioquic.buffer
class Buffer:
+ def push_uint16(self, v: int) -> None:
+ """
+ Push a 16-bit unsigned integer.
+ """
+ pack_into("!H", self._data, self._pos, v)
+ self._pos += 2
+
===========changed ref 15===========
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _handle_streams_blocked_frame(
self, context: QuicReceiveContext, frame_type: int, buf: Buffer
) -> None:
"""
Handle a STREAMS_BLOCKED frame.
"""
+ buf.pull_uint_var() # limit
- pull_uint_var(buf) # limit
===========changed ref 16===========
# module: aioquic.tls
def push_list(
+ buf: Buffer, capacity: int, func: Callable[[T], None], values: Sequence[T]
- buf: Buffer, capacity: int, func: Callable[[Buffer, T], None], values: Sequence[T]
) -> None:
"""
Push a list of items.
"""
with push_block(buf, capacity):
for value in values:
+ func(value)
- func(buf, value)
===========changed ref 17===========
# module: aioquic.packet
def pull_new_token_frame(buf: Buffer) -> bytes:
+ length = buf.pull_uint_var()
- length = pull_uint_var(buf)
+ return buf.pull_bytes(length)
- return pull_bytes(buf, length)
===========changed ref 18===========
# module: aioquic.tls
def push_finished(buf: Buffer, finished: Finished) -> None:
+ buf.push_uint8(HandshakeType.FINISHED)
- push_uint8(buf, HandshakeType.FINISHED)
push_opaque(buf, 3, finished.verify_data)
===========changed ref 19===========
# module: aioquic.buffer
- def push_uint64(buf: Buffer, v: int) -> None:
- """
- Push a 64-bit unsigned integer.
- """
- pack_into("!Q", buf._data, buf._pos, v)
- buf._pos += 8
-
===========changed ref 20===========
# module: aioquic.buffer
- def push_uint32(buf: Buffer, v: int) -> None:
- """
- Push a 32-bit unsigned integer.
- """
- pack_into("!L", buf._data, buf._pos, v)
- buf._pos += 4
-
===========changed ref 21===========
# module: aioquic.buffer
- def push_uint16(buf: Buffer, v: int) -> None:
- """
- Push a 16-bit unsigned integer.
- """
- pack_into("!H", buf._data, buf._pos, v)
- buf._pos += 2
-
===========changed ref 22===========
# module: aioquic.tls
def push_opaque(buf: Buffer, capacity: int, value: bytes) -> None:
"""
Push an opaque value prefix by a length.
"""
with push_block(buf, capacity):
+ buf.push_bytes(value)
- push_bytes(buf, value)
|
tests.test_connection/QuicConnectionTest.test_datagram_received_wrong_version
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<11>:<add> builder.buffer.push_bytes(bytes(1200))
<del> push_bytes(builder.buffer, bytes(1200))
|
# module: tests.test_connection
class QuicConnectionTest(TestCase):
def test_datagram_received_wrong_version(self):
<0> client, client_transport = create_standalone_client()
<1> self.assertEqual(client_transport.sent, 1)
<2>
<3> builder = QuicPacketBuilder(
<4> host_cid=client._peer_cid,
<5> peer_cid=client.host_cid,
<6> version=0xFF000011, # DRAFT_16
<7> )
<8> crypto = CryptoPair()
<9> crypto.setup_initial(client.host_cid, is_client=False)
<10> builder.start_packet(PACKET_TYPE_INITIAL, crypto)
<11> push_bytes(builder.buffer, bytes(1200))
<12> builder.end_packet()
<13>
<14> for datagram in builder.flush()[0]:
<15> client.datagram_received(datagram, SERVER_ADDR)
<16> self.assertEqual(client_transport.sent, 1)
<17>
|
===========unchanged ref 0===========
at: aioquic.buffer.Buffer
push_bytes(v: bytes) -> None
at: aioquic.connection.QuicConnection.__init__
self.host_cid = self._host_cids[0].cid
self._peer_cid = os.urandom(8)
at: aioquic.connection.QuicConnection._consume_connection_id
self._peer_cid = connection_id.cid
at: aioquic.connection.QuicConnection.datagram_received
self._peer_cid = header.source_cid
self.host_cid = context.host_cid
at: aioquic.crypto
CryptoPair()
at: aioquic.crypto.CryptoPair
setup_initial(cid: bytes, is_client: bool) -> None
at: aioquic.packet
PACKET_TYPE_INITIAL = PACKET_LONG_HEADER | PACKET_FIXED_BIT | 0x00
at: aioquic.packet_builder
QuicPacketBuilder(*, host_cid: bytes, peer_cid: bytes, version: int, pad_first_datagram: bool=False, packet_number: int=0, peer_token: bytes=b"", spin_bit: bool=False)
at: aioquic.packet_builder.QuicPacketBuilder
flush() -> Tuple[List[bytes], List[QuicSentPacket]]
start_packet(packet_type: int, crypto: CryptoPair) -> None
end_packet() -> bool
at: aioquic.packet_builder.QuicPacketBuilder.__init__
self.buffer = Buffer(PACKET_MAX_SIZE)
at: tests.test_connection
SERVER_ADDR = ("2.3.4.5", 4433)
create_standalone_client()
at: tests.test_connection.FakeTransport.sendto
self.sent += 1
at: unittest.case.TestCase
failureException: Type[BaseException]
longMessage: bool
maxDiff: Optional[int]
_testMethodName: str
_testMethodDoc: str
===========unchanged ref 1===========
assertEqual(first: Any, second: Any, msg: Any=...) -> None
===========changed ref 0===========
# module: aioquic.buffer
class Buffer:
+ def push_bytes(self, v: bytes) -> None:
+ """
+ Push bytes.
+ """
+ end = self._pos + len(v)
+ if end > self._length:
+ raise BufferWriteError
+ self._data[self._pos : end] = v
+ self._pos = end
+
===========changed ref 1===========
# module: aioquic.packet_builder
class QuicPacketBuilder:
def end_packet(self) -> bool:
"""
Ends the current packet.
Returns `True` if the packet contains data, `False` otherwise.
"""
buf = self.buffer
empty = True
packet_size = buf.tell() - self._packet_start
if packet_size > self._header_size:
empty = False
# pad initial datagram
if self._pad_first_datagram:
+ buf.push_bytes(bytes(self.remaining_space))
- push_bytes(buf, bytes(self.remaining_space))
packet_size = buf.tell() - self._packet_start
self._pad_first_datagram = False
# write header
if is_long_header(self._packet_type):
length = (
packet_size
- self._header_size
+ PACKET_NUMBER_SEND_SIZE
+ self._packet_crypto.aead_tag_size
)
buf.seek(self._packet_start)
+ buf.push_uint8(self._packet_type | (PACKET_NUMBER_SEND_SIZE - 1))
- push_uint8(buf, self._packet_type | (PACKET_NUMBER_SEND_SIZE - 1))
+ buf.push_uint32(self._version)
- push_uint32(buf, self._version)
+ buf.push_uint8(
- push_uint8(
- buf,
(encode_cid_length(len(self._peer_cid)) << 4)
+ | encode_cid_length(len(self._host_cid))
- | encode_cid_length(len(self._host_cid)),
)
+ buf.push_bytes(self._peer_cid)
- push_bytes(buf, self._peer_cid)
+ buf.push_bytes(self._host_cid)
- push_bytes(buf, self._host_cid)
if (self._packet_type & PACKET</s>
===========changed ref 2===========
# module: aioquic.packet_builder
class QuicPacketBuilder:
def end_packet(self) -> bool:
# offset: 1
<s>_cid)
- push_bytes(buf, self._host_cid)
if (self._packet_type & PACKET_TYPE_MASK) == PACKET_TYPE_INITIAL:
+ buf.push_uint_var(len(self._peer_token))
- push_uint_var(buf, len(self._peer_token))
+ buf.push_bytes(self._peer_token)
- push_bytes(buf, self._peer_token)
+ buf.push_uint16(length | 0x4000)
- push_uint16(buf, length | 0x4000)
+ buf.push_uint16(self._packet_number & 0xFFFF)
- push_packet_number(buf, self._packet_number)
else:
buf.seek(self._packet_start)
+ buf.push_uint8(
- push_uint8(
- buf,
self._packet_type
| (self._spin_bit << 5)
| (self._packet_crypto.key_phase << 2)
+ | (PACKET_NUMBER_SEND_SIZE - 1)
- | (PACKET_NUMBER_SEND_SIZE - 1),
)
+ buf.push_bytes(self._peer_cid)
- push_bytes(buf, self._peer_cid)
+ buf.push_uint16(self._packet_number & 0xFFFF)
- push_packet_number(buf, self._packet_number)
# 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</s>
===========changed ref 3===========
# module: aioquic.packet_builder
class QuicPacketBuilder:
def end_packet(self) -> bool:
# offset: 2
<s>(padding_size))
- push_bytes(buf, 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(
- push_bytes(
- buf,
self._packet_crypto.encrypt_packet(
plain[0 : self._header_size], plain[self._header_size : packet_size]
+ )
- ),
)
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 is_long_header(self._packet_type):
self._flush_current_datagram()
self._packet_number += 1
else:
# "cancel" the packet
buf.seek(self._packet_start)
self._packet = None
return not empty
===========changed ref 4===========
# module: tests.test_connection
def encode_uint_var(v):
buf = Buffer(capacity=8)
+ buf.push_uint_var(v)
- push_uint_var(buf, v)
return buf.data
|
tests.test_packet_builder/QuicPacketBuilderTest.test_long_header_padding
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<16>:<add> builder.buffer.push_bytes(bytes(100))
<del> push_bytes(builder.buffer, bytes(100))
|
# module: tests.test_packet_builder
class QuicPacketBuilderTest(TestCase):
def test_long_header_padding(self):
<0> builder = QuicPacketBuilder(
<1> host_cid=bytes(8),
<2> packet_number=0,
<3> pad_first_datagram=True,
<4> peer_cid=bytes(8),
<5> peer_token=b"",
<6> spin_bit=False,
<7> version=QuicProtocolVersion.DRAFT_20,
<8> )
<9> crypto = CryptoPair()
<10> crypto.setup_initial(bytes(8), is_client=True)
<11>
<12> # INITIAL, fully padded
<13> builder.start_packet(PACKET_TYPE_INITIAL, crypto)
<14> self.assertEqual(builder.remaining_space, 1237)
<15> builder.start_frame(QuicFrameType.CRYPTO)
<16> push_bytes(builder.buffer, bytes(100))
<17> self.assertTrue(builder.end_packet())
<18> self.assertEqual(builder.buffer.tell(), 1280)
<19>
<20> # check datagrams
<21> datagrams, packets = builder.flush()
<22> self.assertEqual(len(datagrams), 1)
<23> self.assertEqual(len(datagrams[0]), 1280)
<24> self.assertEqual(
<25> packets,
<26> [
<27> QuicSentPacket(
<28> epoch=Epoch.INITIAL,
<29> in_flight=True,
<30> is_ack_eliciting=True,
<31> is_crypto_packet=True,
<32> packet_number=0,
<33> sent_bytes=1280,
<34> )
<35> ],
<36> )
<37>
|
===========unchanged ref 0===========
at: aioquic.buffer.Buffer
tell() -> int
at: aioquic.crypto
CryptoPair()
at: aioquic.crypto.CryptoPair
setup_initial(cid: bytes, is_client: bool) -> None
at: aioquic.packet
PACKET_TYPE_INITIAL = PACKET_LONG_HEADER | PACKET_FIXED_BIT | 0x00
QuicProtocolVersion(x: Union[str, bytes, bytearray], base: int)
QuicProtocolVersion(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
QuicFrameType(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
QuicFrameType(x: Union[str, bytes, bytearray], base: int)
at: aioquic.packet_builder
QuicSentPacket(epoch: Epoch, in_flight: bool, is_ack_eliciting: bool, is_crypto_packet: bool, packet_number: int, sent_time: Optional[float]=None, sent_bytes: int=0, delivery_handlers: List[Tuple[QuicDeliveryHandler, Any]]=field(
default_factory=list
))
QuicPacketBuilder(*, host_cid: bytes, peer_cid: bytes, version: int, pad_first_datagram: bool=False, packet_number: int=0, peer_token: bytes=b"", spin_bit: bool=False)
at: aioquic.packet_builder.QuicPacketBuilder
flush() -> Tuple[List[bytes], List[QuicSentPacket]]
start_frame(frame_type: int, handler: Optional[QuicDeliveryHandler]=None, args: Sequence[Any]=[]) -> None
start_packet(packet_type: int, crypto: CryptoPair) -> None
end_packet() -> bool
at: aioquic.packet_builder.QuicPacketBuilder.__init__
self.buffer = Buffer(PACKET_MAX_SIZE)
at: aioquic.packet_builder.QuicSentPacket
epoch: Epoch
===========unchanged ref 1===========
in_flight: bool
is_ack_eliciting: bool
is_crypto_packet: bool
packet_number: int
sent_time: Optional[float] = None
sent_bytes: int = 0
delivery_handlers: List[Tuple[QuicDeliveryHandler, Any]] = field(
default_factory=list
)
at: aioquic.tls
Epoch()
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
===========changed ref 0===========
# module: aioquic.packet_builder
class QuicPacketBuilder:
def start_frame(
self,
frame_type: int,
handler: Optional[QuicDeliveryHandler] = None,
args: Sequence[Any] = [],
) -> None:
"""
Starts a new frame.
"""
+ self.buffer.push_uint_var(frame_type)
- push_uint_var(self.buffer, frame_type)
if frame_type not in NON_ACK_ELICITING_FRAME_TYPES:
# FIXME: in_flight != is_ack_eliciting
self._packet.in_flight = True
self._packet.is_ack_eliciting = True
self._ack_eliciting = True
if frame_type == QuicFrameType.CRYPTO:
self._packet.is_crypto_packet = True
if handler is not None:
self._packet.delivery_handlers.append((handler, args))
===========changed ref 1===========
# module: aioquic.packet_builder
class QuicPacketBuilder:
def end_packet(self) -> bool:
"""
Ends the current packet.
Returns `True` if the packet contains data, `False` otherwise.
"""
buf = self.buffer
empty = True
packet_size = buf.tell() - self._packet_start
if packet_size > self._header_size:
empty = False
# pad initial datagram
if self._pad_first_datagram:
+ buf.push_bytes(bytes(self.remaining_space))
- push_bytes(buf, bytes(self.remaining_space))
packet_size = buf.tell() - self._packet_start
self._pad_first_datagram = False
# write header
if is_long_header(self._packet_type):
length = (
packet_size
- self._header_size
+ PACKET_NUMBER_SEND_SIZE
+ self._packet_crypto.aead_tag_size
)
buf.seek(self._packet_start)
+ buf.push_uint8(self._packet_type | (PACKET_NUMBER_SEND_SIZE - 1))
- push_uint8(buf, self._packet_type | (PACKET_NUMBER_SEND_SIZE - 1))
+ buf.push_uint32(self._version)
- push_uint32(buf, self._version)
+ buf.push_uint8(
- push_uint8(
- buf,
(encode_cid_length(len(self._peer_cid)) << 4)
+ | encode_cid_length(len(self._host_cid))
- | encode_cid_length(len(self._host_cid)),
)
+ buf.push_bytes(self._peer_cid)
- push_bytes(buf, self._peer_cid)
+ buf.push_bytes(self._host_cid)
- push_bytes(buf, self._host_cid)
if (self._packet_type & PACKET</s>
===========changed ref 2===========
# module: aioquic.packet_builder
class QuicPacketBuilder:
def end_packet(self) -> bool:
# offset: 1
<s>_cid)
- push_bytes(buf, self._host_cid)
if (self._packet_type & PACKET_TYPE_MASK) == PACKET_TYPE_INITIAL:
+ buf.push_uint_var(len(self._peer_token))
- push_uint_var(buf, len(self._peer_token))
+ buf.push_bytes(self._peer_token)
- push_bytes(buf, self._peer_token)
+ buf.push_uint16(length | 0x4000)
- push_uint16(buf, length | 0x4000)
+ buf.push_uint16(self._packet_number & 0xFFFF)
- push_packet_number(buf, self._packet_number)
else:
buf.seek(self._packet_start)
+ buf.push_uint8(
- push_uint8(
- buf,
self._packet_type
| (self._spin_bit << 5)
| (self._packet_crypto.key_phase << 2)
+ | (PACKET_NUMBER_SEND_SIZE - 1)
- | (PACKET_NUMBER_SEND_SIZE - 1),
)
+ buf.push_bytes(self._peer_cid)
- push_bytes(buf, self._peer_cid)
+ buf.push_uint16(self._packet_number & 0xFFFF)
- push_packet_number(buf, self._packet_number)
# 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</s>
|
tests.test_packet_builder/QuicPacketBuilderTest.test_long_header_then_short_header
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<15>:<add> builder.buffer.push_bytes(bytes(builder.remaining_space))
<del> push_bytes(builder.buffer, bytes(builder.remaining_space))
<23>:<add> builder.buffer.push_bytes(bytes(builder.remaining_space))
<del> push_bytes(builder.buffer, bytes(builder.remaining_space))
|
# module: tests.test_packet_builder
class QuicPacketBuilderTest(TestCase):
def test_long_header_then_short_header(self):
<0> builder = QuicPacketBuilder(
<1> host_cid=bytes(8),
<2> packet_number=0,
<3> peer_cid=bytes(8),
<4> peer_token=b"",
<5> spin_bit=False,
<6> version=QuicProtocolVersion.DRAFT_20,
<7> )
<8> crypto = CryptoPair()
<9> crypto.setup_initial(bytes(8), is_client=True)
<10>
<11> # INITIAL, fully padded
<12> builder.start_packet(PACKET_TYPE_INITIAL, crypto)
<13> self.assertEqual(builder.remaining_space, 1237)
<14> builder.start_frame(QuicFrameType.CRYPTO)
<15> push_bytes(builder.buffer, bytes(builder.remaining_space))
<16> self.assertTrue(builder.end_packet())
<17> self.assertEqual(builder.buffer.tell(), 1280)
<18>
<19> # ONE_RTT, fully padded
<20> builder.start_packet(PACKET_TYPE_ONE_RTT, crypto)
<21> self.assertEqual(builder.remaining_space, 1253)
<22> builder.start_frame(QuicFrameType.STREAM_BASE)
<23> push_bytes(builder.buffer, bytes(builder.remaining_space))
<24> self.assertTrue(builder.end_packet())
<25> self.assertEqual(builder.buffer.tell(), 0)
<26>
<27> # check datagrams
<28> datagrams, packets = builder.flush()
<29> self.assertEqual(len(datagrams), 2)
<30> self.assertEqual(len(datagrams[0]), 1280)
<31> self.assertEqual(len(datagrams[1]), 1280)
<32> self.assertEqual(
<33> packets,
<34> [
<35> QuicSentPacket(
<36> epoch=Epoch.INITIAL,
<37> in_flight=True,
<38> is_ack_eliciting=True,</s>
|
===========below chunk 0===========
# module: tests.test_packet_builder
class QuicPacketBuilderTest(TestCase):
def test_long_header_then_short_header(self):
# offset: 1
packet_number=0,
sent_bytes=1280,
),
QuicSentPacket(
epoch=Epoch.ONE_RTT,
in_flight=True,
is_ack_eliciting=True,
is_crypto_packet=False,
packet_number=1,
sent_bytes=1280,
),
],
)
===========unchanged ref 0===========
at: aioquic.buffer.Buffer
tell() -> int
at: aioquic.crypto
CryptoPair()
at: aioquic.crypto.CryptoPair
setup_initial(cid: bytes, is_client: bool) -> None
at: aioquic.packet
PACKET_TYPE_INITIAL = PACKET_LONG_HEADER | PACKET_FIXED_BIT | 0x00
PACKET_TYPE_ONE_RTT = PACKET_FIXED_BIT
QuicProtocolVersion(x: Union[str, bytes, bytearray], base: int)
QuicProtocolVersion(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
QuicFrameType(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
QuicFrameType(x: Union[str, bytes, bytearray], base: int)
at: aioquic.packet_builder
QuicSentPacket(epoch: Epoch, in_flight: bool, is_ack_eliciting: bool, is_crypto_packet: bool, packet_number: int, sent_time: Optional[float]=None, sent_bytes: int=0, delivery_handlers: List[Tuple[QuicDeliveryHandler, Any]]=field(
default_factory=list
))
QuicPacketBuilder(*, host_cid: bytes, peer_cid: bytes, version: int, pad_first_datagram: bool=False, packet_number: int=0, peer_token: bytes=b"", spin_bit: bool=False)
at: aioquic.packet_builder.QuicPacketBuilder
flush() -> Tuple[List[bytes], List[QuicSentPacket]]
start_frame(frame_type: int, handler: Optional[QuicDeliveryHandler]=None, args: Sequence[Any]=[]) -> None
start_packet(packet_type: int, crypto: CryptoPair) -> None
end_packet() -> bool
at: aioquic.packet_builder.QuicPacketBuilder.__init__
self.buffer = Buffer(PACKET_MAX_SIZE)
===========unchanged ref 1===========
at: aioquic.tls
Epoch()
at: unittest.case.TestCase
assertEqual(first: Any, second: Any, msg: Any=...) -> None
assertTrue(expr: Any, msg: Any=...) -> None
===========changed ref 0===========
# module: aioquic.packet_builder
class QuicPacketBuilder:
def start_frame(
self,
frame_type: int,
handler: Optional[QuicDeliveryHandler] = None,
args: Sequence[Any] = [],
) -> None:
"""
Starts a new frame.
"""
+ self.buffer.push_uint_var(frame_type)
- push_uint_var(self.buffer, frame_type)
if frame_type not in NON_ACK_ELICITING_FRAME_TYPES:
# FIXME: in_flight != is_ack_eliciting
self._packet.in_flight = True
self._packet.is_ack_eliciting = True
self._ack_eliciting = True
if frame_type == QuicFrameType.CRYPTO:
self._packet.is_crypto_packet = True
if handler is not None:
self._packet.delivery_handlers.append((handler, args))
===========changed ref 1===========
# module: aioquic.packet_builder
class QuicPacketBuilder:
def end_packet(self) -> bool:
"""
Ends the current packet.
Returns `True` if the packet contains data, `False` otherwise.
"""
buf = self.buffer
empty = True
packet_size = buf.tell() - self._packet_start
if packet_size > self._header_size:
empty = False
# pad initial datagram
if self._pad_first_datagram:
+ buf.push_bytes(bytes(self.remaining_space))
- push_bytes(buf, bytes(self.remaining_space))
packet_size = buf.tell() - self._packet_start
self._pad_first_datagram = False
# write header
if is_long_header(self._packet_type):
length = (
packet_size
- self._header_size
+ PACKET_NUMBER_SEND_SIZE
+ self._packet_crypto.aead_tag_size
)
buf.seek(self._packet_start)
+ buf.push_uint8(self._packet_type | (PACKET_NUMBER_SEND_SIZE - 1))
- push_uint8(buf, self._packet_type | (PACKET_NUMBER_SEND_SIZE - 1))
+ buf.push_uint32(self._version)
- push_uint32(buf, self._version)
+ buf.push_uint8(
- push_uint8(
- buf,
(encode_cid_length(len(self._peer_cid)) << 4)
+ | encode_cid_length(len(self._host_cid))
- | encode_cid_length(len(self._host_cid)),
)
+ buf.push_bytes(self._peer_cid)
- push_bytes(buf, self._peer_cid)
+ buf.push_bytes(self._host_cid)
- push_bytes(buf, self._host_cid)
if (self._packet_type & PACKET</s>
===========changed ref 2===========
# module: aioquic.packet_builder
class QuicPacketBuilder:
def end_packet(self) -> bool:
# offset: 1
<s>_cid)
- push_bytes(buf, self._host_cid)
if (self._packet_type & PACKET_TYPE_MASK) == PACKET_TYPE_INITIAL:
+ buf.push_uint_var(len(self._peer_token))
- push_uint_var(buf, len(self._peer_token))
+ buf.push_bytes(self._peer_token)
- push_bytes(buf, self._peer_token)
+ buf.push_uint16(length | 0x4000)
- push_uint16(buf, length | 0x4000)
+ buf.push_uint16(self._packet_number & 0xFFFF)
- push_packet_number(buf, self._packet_number)
else:
buf.seek(self._packet_start)
+ buf.push_uint8(
- push_uint8(
- buf,
self._packet_type
| (self._spin_bit << 5)
| (self._packet_crypto.key_phase << 2)
+ | (PACKET_NUMBER_SEND_SIZE - 1)
- | (PACKET_NUMBER_SEND_SIZE - 1),
)
+ buf.push_bytes(self._peer_cid)
- push_bytes(buf, self._peer_cid)
+ buf.push_uint16(self._packet_number & 0xFFFF)
- push_packet_number(buf, self._packet_number)
# 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</s>
|
tests.test_packet_builder/QuicPacketBuilderTest.test_long_header_then_long_header
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<15>:<add> builder.buffer.push_bytes(bytes(199))
<del> push_bytes(builder.buffer, bytes(199))
<25>:<add> builder.buffer.push_bytes(bytes(299))
<del> push_bytes(builder.buffer, bytes(299))
<34>:<add> builder.buffer.push_bytes(bytes(299))
<del> push_bytes(builder.buffer, bytes(299))
|
# module: tests.test_packet_builder
class QuicPacketBuilderTest(TestCase):
def test_long_header_then_long_header(self):
<0> builder = QuicPacketBuilder(
<1> host_cid=bytes(8),
<2> packet_number=0,
<3> peer_cid=bytes(8),
<4> peer_token=b"",
<5> spin_bit=False,
<6> version=QuicProtocolVersion.DRAFT_20,
<7> )
<8> crypto = CryptoPair()
<9> crypto.setup_initial(bytes(8), is_client=True)
<10>
<11> # INITIAL
<12> builder.start_packet(PACKET_TYPE_INITIAL, crypto)
<13> self.assertEqual(builder.remaining_space, 1237)
<14> builder.start_frame(QuicFrameType.CRYPTO)
<15> push_bytes(builder.buffer, bytes(199))
<16> self.assertEqual(builder.buffer.tell(), 227)
<17> self.assertTrue(builder.end_packet())
<18> self.assertEqual(builder.buffer.tell(), 243)
<19>
<20> # HANDSHAKE
<21> builder.start_packet(PACKET_TYPE_HANDSHAKE, crypto)
<22> self.assertEqual(builder.buffer.tell(), 269)
<23> self.assertEqual(builder.remaining_space, 995)
<24> builder.start_frame(QuicFrameType.CRYPTO)
<25> push_bytes(builder.buffer, bytes(299))
<26> self.assertEqual(builder.buffer.tell(), 569)
<27> self.assertTrue(builder.end_packet())
<28> self.assertEqual(builder.buffer.tell(), 585)
<29>
<30> # ONE_RTT
<31> builder.start_packet(PACKET_TYPE_ONE_RTT, crypto)
<32> self.assertEqual(builder.remaining_space, 668)
<33> builder.start_frame(QuicFrameType.CRYPTO)
<34> push_bytes(builder.buffer, bytes(299))
<35> self.assertTrue(builder.end_packet())
<36> </s>
|
===========below chunk 0===========
# module: tests.test_packet_builder
class QuicPacketBuilderTest(TestCase):
def test_long_header_then_long_header(self):
# offset: 1
# check datagrams
datagrams, packets = builder.flush()
self.assertEqual(len(datagrams), 1)
self.assertEqual(len(datagrams[0]), 912)
self.assertEqual(
packets,
[
QuicSentPacket(
epoch=Epoch.INITIAL,
in_flight=True,
is_ack_eliciting=True,
is_crypto_packet=True,
packet_number=0,
sent_bytes=243,
),
QuicSentPacket(
epoch=Epoch.HANDSHAKE,
in_flight=True,
is_ack_eliciting=True,
is_crypto_packet=True,
packet_number=1,
sent_bytes=342,
),
QuicSentPacket(
epoch=Epoch.ONE_RTT,
in_flight=True,
is_ack_eliciting=True,
is_crypto_packet=True,
packet_number=2,
sent_bytes=327,
),
],
)
===========unchanged ref 0===========
at: aioquic.buffer.Buffer
tell() -> int
at: aioquic.crypto
CryptoPair()
at: aioquic.crypto.CryptoPair
setup_initial(cid: bytes, is_client: bool) -> None
at: aioquic.packet
PACKET_TYPE_INITIAL = PACKET_LONG_HEADER | PACKET_FIXED_BIT | 0x00
PACKET_TYPE_HANDSHAKE = PACKET_LONG_HEADER | PACKET_FIXED_BIT | 0x20
PACKET_TYPE_ONE_RTT = PACKET_FIXED_BIT
QuicProtocolVersion(x: Union[str, bytes, bytearray], base: int)
QuicProtocolVersion(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
QuicFrameType(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
QuicFrameType(x: Union[str, bytes, bytearray], base: int)
at: aioquic.packet_builder
QuicSentPacket(epoch: Epoch, in_flight: bool, is_ack_eliciting: bool, is_crypto_packet: bool, packet_number: int, sent_time: Optional[float]=None, sent_bytes: int=0, delivery_handlers: List[Tuple[QuicDeliveryHandler, Any]]=field(
default_factory=list
))
QuicPacketBuilder(*, host_cid: bytes, peer_cid: bytes, version: int, pad_first_datagram: bool=False, packet_number: int=0, peer_token: bytes=b"", spin_bit: bool=False)
at: aioquic.packet_builder.QuicPacketBuilder
start_frame(frame_type: int, handler: Optional[QuicDeliveryHandler]=None, args: Sequence[Any]=[]) -> None
start_packet(packet_type: int, crypto: CryptoPair) -> None
end_packet() -> bool
===========unchanged ref 1===========
at: aioquic.packet_builder.QuicPacketBuilder.__init__
self.buffer = Buffer(PACKET_MAX_SIZE)
at: aioquic.tls
Epoch()
at: unittest.case.TestCase
assertEqual(first: Any, second: Any, msg: Any=...) -> None
assertTrue(expr: Any, msg: Any=...) -> None
===========changed ref 0===========
# module: aioquic.packet_builder
class QuicPacketBuilder:
def start_frame(
self,
frame_type: int,
handler: Optional[QuicDeliveryHandler] = None,
args: Sequence[Any] = [],
) -> None:
"""
Starts a new frame.
"""
+ self.buffer.push_uint_var(frame_type)
- push_uint_var(self.buffer, frame_type)
if frame_type not in NON_ACK_ELICITING_FRAME_TYPES:
# FIXME: in_flight != is_ack_eliciting
self._packet.in_flight = True
self._packet.is_ack_eliciting = True
self._ack_eliciting = True
if frame_type == QuicFrameType.CRYPTO:
self._packet.is_crypto_packet = True
if handler is not None:
self._packet.delivery_handlers.append((handler, args))
===========changed ref 1===========
# module: aioquic.packet_builder
class QuicPacketBuilder:
def end_packet(self) -> bool:
"""
Ends the current packet.
Returns `True` if the packet contains data, `False` otherwise.
"""
buf = self.buffer
empty = True
packet_size = buf.tell() - self._packet_start
if packet_size > self._header_size:
empty = False
# pad initial datagram
if self._pad_first_datagram:
+ buf.push_bytes(bytes(self.remaining_space))
- push_bytes(buf, bytes(self.remaining_space))
packet_size = buf.tell() - self._packet_start
self._pad_first_datagram = False
# write header
if is_long_header(self._packet_type):
length = (
packet_size
- self._header_size
+ PACKET_NUMBER_SEND_SIZE
+ self._packet_crypto.aead_tag_size
)
buf.seek(self._packet_start)
+ buf.push_uint8(self._packet_type | (PACKET_NUMBER_SEND_SIZE - 1))
- push_uint8(buf, self._packet_type | (PACKET_NUMBER_SEND_SIZE - 1))
+ buf.push_uint32(self._version)
- push_uint32(buf, self._version)
+ buf.push_uint8(
- push_uint8(
- buf,
(encode_cid_length(len(self._peer_cid)) << 4)
+ | encode_cid_length(len(self._host_cid))
- | encode_cid_length(len(self._host_cid)),
)
+ buf.push_bytes(self._peer_cid)
- push_bytes(buf, self._peer_cid)
+ buf.push_bytes(self._host_cid)
- push_bytes(buf, self._host_cid)
if (self._packet_type & PACKET</s>
|
tests.test_packet_builder/QuicPacketBuilderTest.test_short_header_padding
|
Modified
|
aiortc~aioquic
|
d2fcbad2c99436b01c87ee9dd23e1223e90fdd15
|
[buffer] make basic operations Buffer methods
|
<15>:<add> builder.buffer.push_bytes(bytes(builder.remaining_space))
<del> push_bytes(builder.buffer, bytes(builder.remaining_space))
|
# module: tests.test_packet_builder
class QuicPacketBuilderTest(TestCase):
def test_short_header_padding(self):
<0> builder = QuicPacketBuilder(
<1> host_cid=bytes(8),
<2> packet_number=0,
<3> peer_cid=bytes(8),
<4> peer_token=b"",
<5> spin_bit=False,
<6> version=QuicProtocolVersion.DRAFT_20,
<7> )
<8> crypto = CryptoPair()
<9> crypto.setup_initial(bytes(8), is_client=True)
<10>
<11> # ONE_RTT, fully padded
<12> builder.start_packet(PACKET_TYPE_ONE_RTT, crypto)
<13> self.assertEqual(builder.remaining_space, 1253)
<14> builder.start_frame(QuicFrameType.CRYPTO)
<15> push_bytes(builder.buffer, bytes(builder.remaining_space))
<16> self.assertTrue(builder.end_packet())
<17>
<18> # check builder
<19> self.assertEqual(builder.buffer.tell(), 0)
<20> self.assertEqual(builder.packet_number, 1)
<21>
<22> # check datagrams
<23> datagrams, packets = builder.flush()
<24> self.assertEqual(len(datagrams), 1)
<25> self.assertEqual(len(datagrams[0]), 1280)
<26> self.assertEqual(
<27> packets,
<28> [
<29> QuicSentPacket(
<30> epoch=Epoch.ONE_RTT,
<31> in_flight=True,
<32> is_ack_eliciting=True,
<33> is_crypto_packet=True,
<34> packet_number=0,
<35> sent_bytes=1280,
<36> )
<37> ],
<38> )
<39>
|
===========unchanged ref 0===========
at: aioquic.buffer.Buffer
tell() -> int
at: aioquic.crypto
CryptoPair()
at: aioquic.crypto.CryptoPair
setup_initial(cid: bytes, is_client: bool) -> None
at: aioquic.packet
PACKET_TYPE_ONE_RTT = PACKET_FIXED_BIT
QuicProtocolVersion(x: Union[str, bytes, bytearray], base: int)
QuicProtocolVersion(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
QuicFrameType(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
QuicFrameType(x: Union[str, bytes, bytearray], base: int)
at: aioquic.packet_builder
QuicSentPacket(epoch: Epoch, in_flight: bool, is_ack_eliciting: bool, is_crypto_packet: bool, packet_number: int, sent_time: Optional[float]=None, sent_bytes: int=0, delivery_handlers: List[Tuple[QuicDeliveryHandler, Any]]=field(
default_factory=list
))
QuicPacketBuilder(*, host_cid: bytes, peer_cid: bytes, version: int, pad_first_datagram: bool=False, packet_number: int=0, peer_token: bytes=b"", spin_bit: bool=False)
at: aioquic.packet_builder.QuicPacketBuilder
flush() -> Tuple[List[bytes], List[QuicSentPacket]]
start_frame(frame_type: int, handler: Optional[QuicDeliveryHandler]=None, args: Sequence[Any]=[]) -> None
start_packet(packet_type: int, crypto: CryptoPair) -> None
end_packet() -> bool
at: aioquic.packet_builder.QuicPacketBuilder.__init__
self.buffer = Buffer(PACKET_MAX_SIZE)
at: aioquic.tls
Epoch()
===========unchanged ref 1===========
at: unittest.case.TestCase
assertEqual(first: Any, second: Any, msg: Any=...) -> None
assertTrue(expr: Any, msg: Any=...) -> None
===========changed ref 0===========
# module: aioquic.packet_builder
class QuicPacketBuilder:
def start_frame(
self,
frame_type: int,
handler: Optional[QuicDeliveryHandler] = None,
args: Sequence[Any] = [],
) -> None:
"""
Starts a new frame.
"""
+ self.buffer.push_uint_var(frame_type)
- push_uint_var(self.buffer, frame_type)
if frame_type not in NON_ACK_ELICITING_FRAME_TYPES:
# FIXME: in_flight != is_ack_eliciting
self._packet.in_flight = True
self._packet.is_ack_eliciting = True
self._ack_eliciting = True
if frame_type == QuicFrameType.CRYPTO:
self._packet.is_crypto_packet = True
if handler is not None:
self._packet.delivery_handlers.append((handler, args))
===========changed ref 1===========
# module: aioquic.packet_builder
class QuicPacketBuilder:
def end_packet(self) -> bool:
"""
Ends the current packet.
Returns `True` if the packet contains data, `False` otherwise.
"""
buf = self.buffer
empty = True
packet_size = buf.tell() - self._packet_start
if packet_size > self._header_size:
empty = False
# pad initial datagram
if self._pad_first_datagram:
+ buf.push_bytes(bytes(self.remaining_space))
- push_bytes(buf, bytes(self.remaining_space))
packet_size = buf.tell() - self._packet_start
self._pad_first_datagram = False
# write header
if is_long_header(self._packet_type):
length = (
packet_size
- self._header_size
+ PACKET_NUMBER_SEND_SIZE
+ self._packet_crypto.aead_tag_size
)
buf.seek(self._packet_start)
+ buf.push_uint8(self._packet_type | (PACKET_NUMBER_SEND_SIZE - 1))
- push_uint8(buf, self._packet_type | (PACKET_NUMBER_SEND_SIZE - 1))
+ buf.push_uint32(self._version)
- push_uint32(buf, self._version)
+ buf.push_uint8(
- push_uint8(
- buf,
(encode_cid_length(len(self._peer_cid)) << 4)
+ | encode_cid_length(len(self._host_cid))
- | encode_cid_length(len(self._host_cid)),
)
+ buf.push_bytes(self._peer_cid)
- push_bytes(buf, self._peer_cid)
+ buf.push_bytes(self._host_cid)
- push_bytes(buf, self._host_cid)
if (self._packet_type & PACKET</s>
===========changed ref 2===========
# module: aioquic.packet_builder
class QuicPacketBuilder:
def end_packet(self) -> bool:
# offset: 1
<s>_cid)
- push_bytes(buf, self._host_cid)
if (self._packet_type & PACKET_TYPE_MASK) == PACKET_TYPE_INITIAL:
+ buf.push_uint_var(len(self._peer_token))
- push_uint_var(buf, len(self._peer_token))
+ buf.push_bytes(self._peer_token)
- push_bytes(buf, self._peer_token)
+ buf.push_uint16(length | 0x4000)
- push_uint16(buf, length | 0x4000)
+ buf.push_uint16(self._packet_number & 0xFFFF)
- push_packet_number(buf, self._packet_number)
else:
buf.seek(self._packet_start)
+ buf.push_uint8(
- push_uint8(
- buf,
self._packet_type
| (self._spin_bit << 5)
| (self._packet_crypto.key_phase << 2)
+ | (PACKET_NUMBER_SEND_SIZE - 1)
- | (PACKET_NUMBER_SEND_SIZE - 1),
)
+ buf.push_bytes(self._peer_cid)
- push_bytes(buf, self._peer_cid)
+ buf.push_uint16(self._packet_number & 0xFFFF)
- push_packet_number(buf, self._packet_number)
# 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</s>
|
aioquic.crypto/CryptoContext.decrypt_packet
|
Modified
|
aiortc~aioquic
|
6c6843aba0318c037649e2f99b9ebea987801408
|
[crypto] move more code to C
|
<4>:<del> sample_offset = encrypted_offset + PACKET_NUMBER_MAX_SIZE
<5>:<del> sample = packet[sample_offset : sample_offset + SAMPLE_SIZE]
<6>:<del> mask = self.hp.mask(sample)
<7>:<del> packet = bytearray(packet)
<8>:<del>
<9>:<del> if is_long_header(packet[0]):
<10>:<del> # long header
<11>:<del> packet[0] ^= mask[0] & 0x0F
<12>:<del> else:
<13>:<del> # short header
<14>:<del> packet[0] ^= mask[0] & 0x1F
<15>:<del>
<16>:<del> pn_length = (packet[0] & 0x03) + 1
<17>:<del> for i in range(pn_length):
<18>:<del> packet[encrypted_offset + i] ^= mask[1 + i]
<19>:<del> pn = packet[encrypted_offset : encrypted_offset + pn_length]
<20>:<del> plain_header = bytes(packet[: encrypted_offset + pn_length])
<21>:<add> plain_header = self.hp.remove(packet, encrypted_offset)
<add> first_byte = plain_header[0]
<24>:<add> if not is_long_header(first_byte):
<del> if not is_long_header(packet[0]):
<25>:<add> key_phase = (first_byte & 4) >> 2
<del> key_phase = (packet[0] & 4) >> 2
<30>:<del> nonce = crypto.iv[:-pn_length] + bytes(
<31>:<del> crypto.iv[i - pn_length] ^ pn[i] for i in range(pn_length)
<32>:<del> )
<34>:<add> crypto.iv, packet[len(plain_header) :], plain_header
<del> nonce, bytes(packet[encrypted_offset + pn_length :]), plain_header
<39>:<add> pn_length = (first_byte & 0x03) + 1
<40>:<add> packet_number = (packet_number << 8) | plain_header[encrypted_offset + i]
<del> packet_number =
|
# module: aioquic.crypto
class CryptoContext:
def decrypt_packet(
self, packet: bytes, encrypted_offset: int, expected_packet_number: int
) -> Tuple[bytes, bytes, int, bool]:
<0> if self.aead is None:
<1> raise CryptoError("Decryption key is not available")
<2>
<3> # header protection
<4> sample_offset = encrypted_offset + PACKET_NUMBER_MAX_SIZE
<5> sample = packet[sample_offset : sample_offset + SAMPLE_SIZE]
<6> mask = self.hp.mask(sample)
<7> packet = bytearray(packet)
<8>
<9> if is_long_header(packet[0]):
<10> # long header
<11> packet[0] ^= mask[0] & 0x0F
<12> else:
<13> # short header
<14> packet[0] ^= mask[0] & 0x1F
<15>
<16> pn_length = (packet[0] & 0x03) + 1
<17> for i in range(pn_length):
<18> packet[encrypted_offset + i] ^= mask[1 + i]
<19> pn = packet[encrypted_offset : encrypted_offset + pn_length]
<20> plain_header = bytes(packet[: encrypted_offset + pn_length])
<21>
<22> # detect key phase change
<23> crypto = self
<24> if not is_long_header(packet[0]):
<25> key_phase = (packet[0] & 4) >> 2
<26> if key_phase != self.key_phase:
<27> crypto = self.next_key_phase()
<28>
<29> # payload protection
<30> nonce = crypto.iv[:-pn_length] + bytes(
<31> crypto.iv[i - pn_length] ^ pn[i] for i in range(pn_length)
<32> )
<33> payload = crypto.aead.decrypt(
<34> nonce, bytes(packet[encrypted_offset + pn_length :]), plain_header
<35> )
<36>
<37> # packet number
<38> packet_number = 0
<39> for i in range(pn_length):
<40> packet_number =</s>
|
===========below chunk 0===========
# module: aioquic.crypto
class CryptoContext:
def decrypt_packet(
self, packet: bytes, encrypted_offset: int, expected_packet_number: int
) -> Tuple[bytes, bytes, int, bool]:
# offset: 1
packet_number = decode_packet_number(
packet_number, pn_length * 8, expected_packet_number
)
return plain_header, payload, packet_number, crypto != self
===========unchanged ref 0===========
at: aioquic._crypto
CryptoError(*args: object)
at: aioquic._crypto.AEAD
decrypt(nonce: bytes, data: bytes, associated_data: bytes) -> bytes
encrypt(nonce: bytes, data: bytes, associated_data: bytes) -> bytes
at: aioquic._crypto.HeaderProtection
apply(plain_header: bytes, protected_payload: bytes) -> bytes
remove(packet: bytes, encrypted_offset: int) -> bytes
at: aioquic.crypto
CryptoContext(key_phase: int=0)
at: aioquic.crypto.CryptoContext.__init__
self.aead: Optional[AEAD]
self.cipher_suite: Optional[CipherSuite]
self.hp: Optional[HeaderProtection]
self.iv: Optional[bytes]
self.key_phase = key_phase
at: aioquic.crypto.CryptoContext.apply_key_phase
self.aead = crypto.aead
self.iv = crypto.iv
self.key_phase = crypto.key_phase
at: aioquic.crypto.CryptoContext.setup
self.hp = HeaderProtection(hp_cipher_name, hp)
key, self.iv, hp = derive_key_iv_hp(cipher_suite, secret)
key, self.iv, hp = derive_key_iv_hp(cipher_suite, secret)
self.aead = AEAD(aead_cipher_name, key)
self.cipher_suite = cipher_suite
at: aioquic.crypto.CryptoContext.teardown
self.aead = None
self.cipher_suite = None
self.hp = None
self.iv = None
at: aioquic.packet
decode_packet_number(truncated: int, num_bits: int, expected: int) -> int
is_long_header(first_byte: int) -> bool
at: aioquic.tls
cipher_suite_hash(cipher_suite: CipherSuite) -> hashes.HashAlgorithm
===========unchanged ref 1===========
at: typing
Tuple = _TupleType(tuple, -1, inst=False, name='Tuple')
|
aioquic.crypto/CryptoContext.encrypt_packet
|
Modified
|
aiortc~aioquic
|
6c6843aba0318c037649e2f99b9ebea987801408
|
[crypto] move more code to C
|
<2>:<del> pn_length = (plain_header[0] & 0x03) + 1
<3>:<del> pn_offset = len(plain_header) - pn_length
<4>:<del> pn = plain_header[pn_offset : pn_offset + pn_length]
<5>:<del>
<7>:<del> nonce = self.iv[:-pn_length] + bytes(
<8>:<del> self.iv[i - pn_length] ^ pn[i] for i in range(pn_length)
<9>:<del> )
<10>:<add> protected_payload = self.aead.encrypt(self.iv, plain_payload, plain_header)
<del> protected_payload = self.aead.encrypt(nonce, plain_payload, plain_header)
<13>:<del> sample_offset = PACKET_NUMBER_MAX_SIZE - pn_length
<14>:<del> sample = protected_payload[sample_offset : sample_offset + SAMPLE_SIZE]
<15>:<del> mask = self.hp.mask(sample)
<16>:<add> return self.hp.apply(plain_header, protected_payload)
<17>:<del> packet = bytearray(plain_header + protected_payload)
<18>:<del> if is_long_header(packet[0]):
<19>:<del> # long header
<20>:<del> packet[0] ^= mask[0] & 0x0F
<21>:<del> else:
<22>:<del> # short header
<23>:<del> packet[0] ^= mask[0] & 0x1F
<24>:<del>
<25>:<del> for i in range(pn_length):
<26>:<del> packet[pn_offset + i] ^= mask[1 + i]
<27>:<del>
<28>:<del> return bytes(packet)
<29>:<del>
|
# module: aioquic.crypto
class CryptoContext:
def encrypt_packet(self, plain_header: bytes, plain_payload: bytes) -> bytes:
<0> assert self.is_valid(), "Encryption key is not available"
<1>
<2> pn_length = (plain_header[0] & 0x03) + 1
<3> pn_offset = len(plain_header) - pn_length
<4> pn = plain_header[pn_offset : pn_offset + pn_length]
<5>
<6> # payload protection
<7> nonce = self.iv[:-pn_length] + bytes(
<8> self.iv[i - pn_length] ^ pn[i] for i in range(pn_length)
<9> )
<10> protected_payload = self.aead.encrypt(nonce, plain_payload, plain_header)
<11>
<12> # header protection
<13> sample_offset = PACKET_NUMBER_MAX_SIZE - pn_length
<14> sample = protected_payload[sample_offset : sample_offset + SAMPLE_SIZE]
<15> mask = self.hp.mask(sample)
<16>
<17> packet = bytearray(plain_header + protected_payload)
<18> if is_long_header(packet[0]):
<19> # long header
<20> packet[0] ^= mask[0] & 0x0F
<21> else:
<22> # short header
<23> packet[0] ^= mask[0] & 0x1F
<24>
<25> for i in range(pn_length):
<26> packet[pn_offset + i] ^= mask[1 + i]
<27>
<28> return bytes(packet)
<29>
|
===========unchanged ref 0===========
at: aioquic._crypto
AEAD(cipher_name: bytes, key: bytes)
HeaderProtection(cipher_name: bytes, key: bytes)
at: aioquic.crypto
CIPHER_SUITES = {
CipherSuite.AES_128_GCM_SHA256: (b"aes-128-ecb", b"aes-128-gcm"),
CipherSuite.AES_256_GCM_SHA384: (b"aes-256-ecb", b"aes-256-gcm"),
CipherSuite.CHACHA20_POLY1305_SHA256: (b"chacha20", b"chacha20-poly1305"),
}
derive_key_iv_hp(cipher_suite: CipherSuite, secret: bytes) -> Tuple[bytes, bytes, bytes]
CryptoContext(key_phase: int=0)
at: aioquic.crypto.CryptoContext.__init__
self.aead: Optional[AEAD]
self.cipher_suite: Optional[CipherSuite]
self.hp: Optional[HeaderProtection]
self.iv: Optional[bytes]
self.secret: Optional[bytes]
at: aioquic.crypto.CryptoContext.apply_key_phase
self.aead = crypto.aead
self.iv = crypto.iv
self.secret = crypto.secret
at: aioquic.crypto.CryptoContext.next_key_phase
algorithm = cipher_suite_hash(self.cipher_suite)
crypto = CryptoContext(key_phase=int(not self.key_phase))
at: aioquic.crypto.CryptoPair._update_key
self._update_key_requested = False
at: aioquic.crypto.CryptoPair.update_key
self._update_key_requested = True
at: aioquic.tls
hkdf_expand_label(algorithm: hashes.HashAlgorithm, secret: bytes, label: bytes, hash_value: bytes, length: int) -> bytes
===========unchanged ref 1===========
CipherSuite(x: Union[str, bytes, bytearray], base: int)
CipherSuite(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
===========changed ref 0===========
# module: aioquic.crypto
class CryptoContext:
def decrypt_packet(
self, packet: bytes, encrypted_offset: int, expected_packet_number: int
) -> Tuple[bytes, bytes, int, bool]:
if self.aead is None:
raise CryptoError("Decryption key is not available")
# header protection
- sample_offset = encrypted_offset + PACKET_NUMBER_MAX_SIZE
- sample = packet[sample_offset : sample_offset + SAMPLE_SIZE]
- mask = self.hp.mask(sample)
- packet = bytearray(packet)
-
- if is_long_header(packet[0]):
- # long header
- packet[0] ^= mask[0] & 0x0F
- else:
- # short header
- packet[0] ^= mask[0] & 0x1F
-
- pn_length = (packet[0] & 0x03) + 1
- for i in range(pn_length):
- packet[encrypted_offset + i] ^= mask[1 + i]
- pn = packet[encrypted_offset : encrypted_offset + pn_length]
- plain_header = bytes(packet[: encrypted_offset + pn_length])
+ plain_header = self.hp.remove(packet, encrypted_offset)
+ first_byte = plain_header[0]
# detect key phase change
crypto = self
+ if not is_long_header(first_byte):
- if not is_long_header(packet[0]):
+ key_phase = (first_byte & 4) >> 2
- key_phase = (packet[0] & 4) >> 2
if key_phase != self.key_phase:
crypto = self.next_key_phase()
# payload protection
- nonce = crypto.iv[:-pn_length] + bytes(
- crypto.iv[i - pn_length] ^ pn[i] for i in range(pn_length)
- )
payload = crypto.aead.decrypt(
+ crypto.iv, packet[len</s>
===========changed ref 1===========
# module: aioquic.crypto
class CryptoContext:
def decrypt_packet(
self, packet: bytes, encrypted_offset: int, expected_packet_number: int
) -> Tuple[bytes, bytes, int, bool]:
# offset: 1
<s>(pn_length)
- )
payload = crypto.aead.decrypt(
+ crypto.iv, packet[len(plain_header) :], plain_header
- nonce, bytes(packet[encrypted_offset + pn_length :]), plain_header
)
# packet number
packet_number = 0
+ pn_length = (first_byte & 0x03) + 1
for i in range(pn_length):
+ packet_number = (packet_number << 8) | plain_header[encrypted_offset + i]
- packet_number = (packet_number << 8) | pn[i]
packet_number = decode_packet_number(
packet_number, pn_length * 8, expected_packet_number
)
return plain_header, payload, packet_number, crypto != self
|
aioquic.crypto/CryptoContext.__init__
|
Modified
|
aiortc~aioquic
|
fd98325cdde0a7fba06827a84f3244219879eec1
|
Add Python 3.6 compatibility
|
<0>:<add> self.aead: Optional[AEAD] = None
<del> self.aead: Optional[AEAD]
<1>:<add> self.cipher_suite: Optional[CipherSuite] = None
<del> self.cipher_suite: Optional[CipherSuite]
<2>:<add> self.hp: Optional[HeaderProtection] = None
<del> self.hp: Optional[HeaderProtection]
<3>:<add> self.iv: Optional[bytes] = None
<del> self.iv: Optional[bytes]
<5>:<add> self.secret: Optional[bytes] = None
<del> self.secret: Optional[bytes]
<7>:<del> self.teardown()
<8>:<del>
|
# module: aioquic.crypto
class CryptoContext:
def __init__(self, key_phase: int = 0) -> None:
<0> self.aead: Optional[AEAD]
<1> self.cipher_suite: Optional[CipherSuite]
<2> self.hp: Optional[HeaderProtection]
<3> self.iv: Optional[bytes]
<4> self.key_phase = key_phase
<5> self.secret: Optional[bytes]
<6>
<7> self.teardown()
<8>
|
===========unchanged ref 0===========
at: aioquic._crypto
HeaderProtection(cipher_name: bytes, key: bytes)
at: aioquic.crypto.CryptoContext.setup
key, self.iv, hp = derive_key_iv_hp(cipher_suite, secret)
self.cipher_suite = cipher_suite
self.hp = HeaderProtection(hp_cipher_name, hp)
self.secret = secret
at: aioquic.crypto.CryptoContext.teardown
self.cipher_suite = None
self.hp = None
self.iv = None
self.secret = None
at: aioquic.tls
CipherSuite(x: Union[str, bytes, bytearray], base: int)
CipherSuite(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
at: typing
Tuple = _TupleType(tuple, -1, inst=False, name='Tuple')
===========changed ref 0===========
+ # module: aioquic.compat
+ class _AsyncGeneratorContextManager(ContextDecorator):
+ def __aenter__(self):
+ return await self.gen.__anext__()
+
===========changed ref 1===========
+ # module: aioquic.compat
+ if asynccontextmanager is None:
+ asynccontextmanager = _asynccontextmanager
+
===========changed ref 2===========
+ # module: aioquic.compat
+ try:
+ from contextlib import asynccontextmanager
+ except ImportError:
+ asynccontextmanager = None
+
===========changed ref 3===========
+ # module: aioquic.compat
+ class _AsyncGeneratorContextManager(ContextDecorator):
+ def __aexit__(self, typ, value, traceback):
+ if typ is not None:
+ if value is None:
+ value = typ()
+ await self.gen.athrow(typ, value, traceback)
+
===========changed ref 4===========
+ # module: aioquic.compat
+ def _asynccontextmanager(func):
+ @wraps(func)
+ def helper(*args, **kwds):
+ return _AsyncGeneratorContextManager(func, args, kwds)
+
+ return helper
+
===========changed ref 5===========
+ # module: aioquic.compat
+ class _AsyncGeneratorContextManager(ContextDecorator):
+ def __init__(self, func, args, kwds):
+ self.gen = func(*args, **kwds)
+ self.func, self.args, self.kwds = func, args, kwds
+ self.__doc__ = func.__doc__
+
|
aioquic.crypto/CryptoContext.decrypt_packet
|
Modified
|
aiortc~aioquic
|
fd98325cdde0a7fba06827a84f3244219879eec1
|
Add Python 3.6 compatibility
|
<12>:<add> crypto = next_key_phase(self)
<del> crypto = self.next_key_phase()
|
# module: aioquic.crypto
class CryptoContext:
def decrypt_packet(
self, packet: bytes, encrypted_offset: int, expected_packet_number: int
) -> Tuple[bytes, bytes, int, bool]:
<0> if self.aead is None:
<1> raise CryptoError("Decryption key is not available")
<2>
<3> # header protection
<4> plain_header = self.hp.remove(packet, encrypted_offset)
<5> first_byte = plain_header[0]
<6>
<7> # detect key phase change
<8> crypto = self
<9> if not is_long_header(first_byte):
<10> key_phase = (first_byte & 4) >> 2
<11> if key_phase != self.key_phase:
<12> crypto = self.next_key_phase()
<13>
<14> # payload protection
<15> payload = crypto.aead.decrypt(
<16> crypto.iv, packet[len(plain_header) :], plain_header
<17> )
<18>
<19> # packet number
<20> packet_number = 0
<21> pn_length = (first_byte & 0x03) + 1
<22> for i in range(pn_length):
<23> packet_number = (packet_number << 8) | plain_header[encrypted_offset + i]
<24> packet_number = decode_packet_number(
<25> packet_number, pn_length * 8, expected_packet_number
<26> )
<27>
<28> return plain_header, payload, packet_number, crypto != self
<29>
|
===========unchanged ref 0===========
at: aioquic._crypto.AEAD
decrypt(nonce: bytes, data: bytes, associated_data: bytes) -> bytes
encrypt(nonce: bytes, data: bytes, associated_data: bytes) -> bytes
at: aioquic._crypto.HeaderProtection
apply(plain_header: bytes, protected_payload: bytes) -> bytes
at: aioquic.crypto
next_key_phase(self: CryptoContext) -> CryptoContext
at: aioquic.crypto.CryptoContext
is_valid() -> bool
at: aioquic.crypto.CryptoContext.__init__
self.aead: Optional[AEAD] = None
self.hp: Optional[HeaderProtection] = None
self.iv: Optional[bytes] = None
self.key_phase = key_phase
at: aioquic.crypto.CryptoContext.decrypt_packet
plain_header = self.hp.remove(packet, encrypted_offset)
first_byte = plain_header[0]
at: aioquic.crypto.CryptoContext.setup
key, self.iv, hp = derive_key_iv_hp(cipher_suite, secret)
self.aead = AEAD(aead_cipher_name, key)
self.hp = HeaderProtection(hp_cipher_name, hp)
at: aioquic.crypto.CryptoContext.teardown
self.aead = None
self.hp = None
self.iv = None
at: aioquic.packet
decode_packet_number(truncated: int, num_bits: int, expected: int) -> int
is_long_header(first_byte: int) -> bool
===========changed ref 0===========
# module: aioquic.crypto
class CryptoContext:
- def apply_key_phase(self, crypto: CryptoContext) -> None:
- self.aead = crypto.aead
- self.iv = crypto.iv
- self.key_phase = crypto.key_phase
- self.secret = crypto.secret
-
===========changed ref 1===========
# module: aioquic.crypto
class CryptoContext:
def __init__(self, key_phase: int = 0) -> None:
+ self.aead: Optional[AEAD] = None
- self.aead: Optional[AEAD]
+ self.cipher_suite: Optional[CipherSuite] = None
- self.cipher_suite: Optional[CipherSuite]
+ self.hp: Optional[HeaderProtection] = None
- self.hp: Optional[HeaderProtection]
+ self.iv: Optional[bytes] = None
- self.iv: Optional[bytes]
self.key_phase = key_phase
+ self.secret: Optional[bytes] = None
- self.secret: Optional[bytes]
- self.teardown()
-
===========changed ref 2===========
+ # module: aioquic.compat
+ class _AsyncGeneratorContextManager(ContextDecorator):
+ def __aenter__(self):
+ return await self.gen.__anext__()
+
===========changed ref 3===========
+ # module: aioquic.compat
+ if asynccontextmanager is None:
+ asynccontextmanager = _asynccontextmanager
+
===========changed ref 4===========
+ # module: aioquic.compat
+ try:
+ from contextlib import asynccontextmanager
+ except ImportError:
+ asynccontextmanager = None
+
===========changed ref 5===========
+ # module: aioquic.compat
+ class _AsyncGeneratorContextManager(ContextDecorator):
+ def __aexit__(self, typ, value, traceback):
+ if typ is not None:
+ if value is None:
+ value = typ()
+ await self.gen.athrow(typ, value, traceback)
+
===========changed ref 6===========
+ # module: aioquic.compat
+ def _asynccontextmanager(func):
+ @wraps(func)
+ def helper(*args, **kwds):
+ return _AsyncGeneratorContextManager(func, args, kwds)
+
+ return helper
+
===========changed ref 7===========
+ # module: aioquic.compat
+ class _AsyncGeneratorContextManager(ContextDecorator):
+ def __init__(self, func, args, kwds):
+ self.gen = func(*args, **kwds)
+ self.func, self.args, self.kwds = func, args, kwds
+ self.__doc__ = func.__doc__
+
|
aioquic.crypto/CryptoPair._update_key
|
Modified
|
aiortc~aioquic
|
fd98325cdde0a7fba06827a84f3244219879eec1
|
Add Python 3.6 compatibility
|
<0>:<add> apply_key_phase(self.recv, next_key_phase(self.recv))
<del> self.recv.apply_key_phase(self.recv.next_key_phase())
<1>:<add> apply_key_phase(self.send, next_key_phase(self.send))
<del> self.send.apply_key_phase(self.send.next_key_phase())
|
# module: aioquic.crypto
class CryptoPair:
def _update_key(self) -> None:
<0> self.recv.apply_key_phase(self.recv.next_key_phase())
<1> self.send.apply_key_phase(self.send.next_key_phase())
<2> self._update_key_requested = False
<3>
|
===========unchanged ref 0===========
at: aioquic.crypto
apply_key_phase(self: CryptoContext, crypto: CryptoContext) -> None
next_key_phase(self: CryptoContext) -> CryptoContext
at: aioquic.crypto.CryptoPair.__init__
self.send = CryptoContext()
self._update_key_requested = False
at: aioquic.crypto.CryptoPair.update_key
self._update_key_requested = True
===========changed ref 0===========
# module: aioquic.crypto
+ def apply_key_phase(self: CryptoContext, crypto: CryptoContext) -> None:
+ self.aead = crypto.aead
+ self.iv = crypto.iv
+ self.key_phase = crypto.key_phase
+ self.secret = crypto.secret
+
===========changed ref 1===========
# module: aioquic.crypto
+ def next_key_phase(self: CryptoContext) -> CryptoContext:
+ algorithm = cipher_suite_hash(self.cipher_suite)
+
+ crypto = CryptoContext(key_phase=int(not self.key_phase))
+ crypto.setup(
+ self.cipher_suite,
+ hkdf_expand_label(
+ algorithm, self.secret, b"traffic upd", b"", algorithm.digest_size
+ ),
+ )
+ return crypto
+
===========changed ref 2===========
# module: aioquic.crypto
class CryptoContext:
- def next_key_phase(self) -> CryptoContext:
- algorithm = cipher_suite_hash(self.cipher_suite)
-
- crypto = CryptoContext(key_phase=int(not self.key_phase))
- crypto.setup(
- self.cipher_suite,
- hkdf_expand_label(
- algorithm, self.secret, b"traffic upd", b"", algorithm.digest_size
- ),
- )
- return crypto
-
===========changed ref 3===========
# module: aioquic.crypto
class CryptoContext:
- def apply_key_phase(self, crypto: CryptoContext) -> None:
- self.aead = crypto.aead
- self.iv = crypto.iv
- self.key_phase = crypto.key_phase
- self.secret = crypto.secret
-
===========changed ref 4===========
# module: aioquic.crypto
class CryptoContext:
def __init__(self, key_phase: int = 0) -> None:
+ self.aead: Optional[AEAD] = None
- self.aead: Optional[AEAD]
+ self.cipher_suite: Optional[CipherSuite] = None
- self.cipher_suite: Optional[CipherSuite]
+ self.hp: Optional[HeaderProtection] = None
- self.hp: Optional[HeaderProtection]
+ self.iv: Optional[bytes] = None
- self.iv: Optional[bytes]
self.key_phase = key_phase
+ self.secret: Optional[bytes] = None
- self.secret: Optional[bytes]
- self.teardown()
-
===========changed ref 5===========
# module: aioquic.crypto
class CryptoContext:
def decrypt_packet(
self, packet: bytes, encrypted_offset: int, expected_packet_number: int
) -> Tuple[bytes, bytes, int, bool]:
if self.aead is None:
raise CryptoError("Decryption key is not available")
# header protection
plain_header = self.hp.remove(packet, encrypted_offset)
first_byte = plain_header[0]
# detect key phase change
crypto = self
if not is_long_header(first_byte):
key_phase = (first_byte & 4) >> 2
if key_phase != self.key_phase:
+ crypto = next_key_phase(self)
- crypto = self.next_key_phase()
# payload protection
payload = crypto.aead.decrypt(
crypto.iv, packet[len(plain_header) :], plain_header
)
# packet number
packet_number = 0
pn_length = (first_byte & 0x03) + 1
for i in range(pn_length):
packet_number = (packet_number << 8) | plain_header[encrypted_offset + i]
packet_number = decode_packet_number(
packet_number, pn_length * 8, expected_packet_number
)
return plain_header, payload, packet_number, crypto != self
===========changed ref 6===========
+ # module: aioquic.compat
+ class _AsyncGeneratorContextManager(ContextDecorator):
+ def __aenter__(self):
+ return await self.gen.__anext__()
+
===========changed ref 7===========
+ # module: aioquic.compat
+ if asynccontextmanager is None:
+ asynccontextmanager = _asynccontextmanager
+
===========changed ref 8===========
+ # module: aioquic.compat
+ try:
+ from contextlib import asynccontextmanager
+ except ImportError:
+ asynccontextmanager = None
+
===========changed ref 9===========
+ # module: aioquic.compat
+ class _AsyncGeneratorContextManager(ContextDecorator):
+ def __aexit__(self, typ, value, traceback):
+ if typ is not None:
+ if value is None:
+ value = typ()
+ await self.gen.athrow(typ, value, traceback)
+
===========changed ref 10===========
+ # module: aioquic.compat
+ def _asynccontextmanager(func):
+ @wraps(func)
+ def helper(*args, **kwds):
+ return _AsyncGeneratorContextManager(func, args, kwds)
+
+ return helper
+
===========changed ref 11===========
+ # module: aioquic.compat
+ class _AsyncGeneratorContextManager(ContextDecorator):
+ def __init__(self, func, args, kwds):
+ self.gen = func(*args, **kwds)
+ self.func, self.args, self.kwds = func, args, kwds
+ self.__doc__ = func.__doc__
+
|
aioquic.connection/QuicConnection._on_timeout
|
Modified
|
aiortc~aioquic
|
3ce6517b33f94bc4074362e6c0a88b5138bfa6c4
|
[connection] work around uvloop's timer
|
<0>:<add> now = self._loop.time()
<4>:<add> if now + K_GRANULARITY >= self._close_at:
<del> if self._loop.time() >= self._close_at:
<10>:<add> self._loss.on_loss_detection_timeout(now=now)
<del> self._loss.on_loss_detection_timeout(now=self._loop.time())
|
# module: aioquic.connection
class QuicConnection(asyncio.DatagramProtocol):
def _on_timeout(self) -> None:
<0> self._timer = None
<1> self._timer_at = None
<2>
<3> # idle timeout
<4> if self._loop.time() >= self._close_at:
<5> self.connection_lost(self._close_exception)
<6> return
<7>
<8> # loss detection timeout
<9> self._logger.info("Loss detection triggered")
<10> self._loss.on_loss_detection_timeout(now=self._loop.time())
<11> self._send_pending()
<12>
|
===========unchanged ref 0===========
at: aioquic.connection.QuicConnection
supported_versions = [QuicProtocolVersion.DRAFT_19, QuicProtocolVersion.DRAFT_20]
connection_lost(exc: Exception) -> None
at: aioquic.connection.QuicConnection.__init__
self._close_at: Optional[float] = None
self._close_exception: Optional[Exception] = None
self._loop = loop
self._logger = QuicConnectionAdapter(
logger, {"host_cid": dump_cid(self.host_cid)}
)
self._loss = QuicPacketRecovery(send_probe=self._send_probe)
self._timer: Optional[asyncio.TimerHandle] = None
self._timer_at: Optional[float] = None
at: aioquic.connection.QuicConnection._close
self._close_at = self._loop.time() + 3 * self._loss.get_probe_timeout()
at: aioquic.connection.QuicConnection._connect
self._close_at = self._loop.time() + self._local_idle_timeout
at: aioquic.connection.QuicConnection._handle_connection_close_frame
self._close_exception = QuicConnectionError(
error_code=error_code,
frame_type=frame_type,
reason_phrase=reason_phrase,
)
at: aioquic.connection.QuicConnection._set_timer
self._timer = None
self._timer = self._loop.call_at(timer_at, self._on_timeout)
self._timer_at = timer_at
at: aioquic.connection.QuicConnection.datagram_received
self._close_exception = exc
self._close_at = now + self._local_idle_timeout
at: aioquic.recovery
K_GRANULARITY = 0.001 # seconds
at: aioquic.recovery.QuicPacketRecovery
on_loss_detection_timeout(now: float) -> None
===========unchanged ref 1===========
at: asyncio.events.AbstractEventLoop
time() -> float
at: logging.LoggerAdapter
logger: Logger
extra: Mapping[str, Any]
info(msg: Any, *args: Any, exc_info: _ExcInfoType=..., stack_info: bool=..., extra: Optional[Dict[str, Any]]=..., **kwargs: Any) -> None
|
aioquic.buffer/Buffer.data_slice
|
Modified
|
aiortc~aioquic
|
b376d541424ec6424730a32881ff59106fa7307b
|
[buffer] tighten checks for out-of-bounds conditions
|
<0>:<add> if (
<add> start < 0
<add> or start > self._length
<add> or end < 0
<add> or end > self._length
<add> or end < start
<add> ):
<add> raise BufferReadError
|
# module: aioquic.buffer
class Buffer:
def data_slice(self, start: int, end: int) -> bytes:
<0> return bytes(self._data[start:end])
<1>
| |
aioquic.buffer/Buffer.seek
|
Modified
|
aiortc~aioquic
|
b376d541424ec6424730a32881ff59106fa7307b
|
[buffer] tighten checks for out-of-bounds conditions
|
<0>:<add> if pos < 0 or pos > self._length:
<add> raise BufferReadError
<del> assert pos <= self._length
|
# module: aioquic.buffer
class Buffer:
def seek(self, pos: int) -> None:
<0> assert pos <= self._length
<1> self._pos = pos
<2>
|
===========unchanged ref 0===========
at: aioquic.buffer
BufferReadError(*args: object)
===========changed ref 0===========
# module: aioquic.buffer
class Buffer:
def data_slice(self, start: int, end: int) -> bytes:
+ if (
+ start < 0
+ or start > self._length
+ or end < 0
+ or end > self._length
+ or end < start
+ ):
+ raise BufferReadError
return bytes(self._data[start:end])
|
aioquic.buffer/Buffer.pull_bytes
|
Modified
|
aiortc~aioquic
|
b376d541424ec6424730a32881ff59106fa7307b
|
[buffer] tighten checks for out-of-bounds conditions
|
<4>:<add> if length < 0 or end > self._length:
<del> if end > self._length:
|
# module: aioquic.buffer
class Buffer:
def pull_bytes(self, length: int) -> bytes:
<0> """
<1> Pull bytes.
<2> """
<3> end = self._pos + length
<4> if end > self._length:
<5> raise BufferReadError
<6> v = bytes(self._data[self._pos : end])
<7> self._pos = end
<8> return v
<9>
|
===========unchanged ref 0===========
at: aioquic.buffer
BufferReadError(*args: object)
at: aioquic.buffer.Buffer.__init__
self._length = len(data)
self._length = capacity
self._pos = 0
at: aioquic.buffer.Buffer.pull_bytes
self._pos = end
at: aioquic.buffer.Buffer.pull_uint16
self._pos += 2
at: aioquic.buffer.Buffer.pull_uint32
self._pos += 4
at: aioquic.buffer.Buffer.pull_uint64
self._pos += 8
at: aioquic.buffer.Buffer.pull_uint8
self._pos += 1
at: aioquic.buffer.Buffer.pull_uint_var
self._pos += 8
self._pos += 2
self._pos += 1
self._pos += 4
at: aioquic.buffer.Buffer.push_bytes
self._pos = end
at: aioquic.buffer.Buffer.push_uint16
self._pos += 2
at: aioquic.buffer.Buffer.push_uint32
self._pos += 4
at: aioquic.buffer.Buffer.push_uint64
self._pos += 8
at: aioquic.buffer.Buffer.push_uint8
self._pos += 1
at: aioquic.buffer.Buffer.push_uint_var
self._pos += 8
self._pos += 2
self._pos += 1
self._pos += 4
===========changed ref 0===========
# module: aioquic.buffer
class Buffer:
def seek(self, pos: int) -> None:
+ if pos < 0 or pos > self._length:
+ raise BufferReadError
- assert pos <= self._length
self._pos = pos
===========changed ref 1===========
# module: aioquic.buffer
class Buffer:
def data_slice(self, start: int, end: int) -> bytes:
+ if (
+ start < 0
+ or start > self._length
+ or end < 0
+ or end > self._length
+ or end < start
+ ):
+ raise BufferReadError
return bytes(self._data[start:end])
|
tests.test_buffer/BufferTest.test_data_slice
|
Modified
|
aiortc~aioquic
|
b376d541424ec6424730a32881ff59106fa7307b
|
[buffer] tighten checks for out-of-bounds conditions
|
<1>:<add> self.assertEqual(buf.data_slice(0, 8), b"\x08\x07\x06\x05\x04\x03\x02\x01")
|
# module: tests.test_buffer
class BufferTest(TestCase):
def test_data_slice(self):
<0> buf = Buffer(data=b"\x08\x07\x06\x05\x04\x03\x02\x01")
<1> self.assertEqual(buf.data_slice(1, 3), b"\x07\x06")
<2>
|
===========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
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.buffer
class Buffer:
def data_slice(self, start: int, end: int) -> bytes:
+ if (
+ start < 0
+ or start > self._length
+ or end < 0
+ or end > self._length
+ or end < start
+ ):
+ raise BufferReadError
return bytes(self._data[start:end])
===========changed ref 1===========
# module: aioquic.buffer
class Buffer:
def seek(self, pos: int) -> None:
+ if pos < 0 or pos > self._length:
+ raise BufferReadError
- assert pos <= self._length
self._pos = pos
===========changed ref 2===========
# module: aioquic.buffer
class Buffer:
def pull_bytes(self, length: int) -> bytes:
"""
Pull bytes.
"""
end = self._pos + length
+ if length < 0 or end > self._length:
- if end > self._length:
raise BufferReadError
v = bytes(self._data[self._pos : end])
self._pos = end
return v
|
tests.test_connection/QuicConnectionTest._test_connect_with_version
|
Modified
|
aiortc~aioquic
|
788ac036d528d4ea24e361fe92b31c87046c1082
|
[tests] refactor some brittle tests
|
<7>:<del> await asyncio.sleep(0)
<12>:<add>
<add> # sends EOF
<add> writer.write(b"done")
<add> writer.write_eof()
<22>:<del> run(client.wait_connected())
<23>:<del> self.assertEqual(client._transport.sent, 4)
<24>:<del> self.assertEqual(server._transport.sent, 3)
<25>:<add> run(asyncio.gather(client.wait_connected(), server.wait_connected()))
<29>:<del> )
<30>:<del> self.assertEqual(
<31>:<del> sequence_numbers(server._peer_cid_available), [1, 2, 3, 4, 5, 6, 7]
<43>:<del> run(asyncio.sleep(0))
<44>:<del> self.assertEqual(client._transport.sent, 7)
|
# module: tests.test_connection
class QuicConnectionTest(TestCase):
def _test_connect_with_version(self, client_versions, server_versions):
<0> async def serve_request(reader, writer):
<1> # check request
<2> request = await reader.read(1024)
<3> self.assertEqual(request, b"ping")
<4>
<5> # send response
<6> writer.write(b"pong")
<7> await asyncio.sleep(0)
<8>
<9> # receives EOF
<10> request = await reader.read()
<11> self.assertEqual(request, b"")
<12>
<13> with client_and_server(
<14> client_options={"supported_versions": client_versions},
<15> server_options={
<16> "stream_handler": lambda reader, writer: asyncio.ensure_future(
<17> serve_request(reader, writer)
<18> ),
<19> "supported_versions": server_versions,
<20> },
<21> ) as (client, server):
<22> run(client.wait_connected())
<23> self.assertEqual(client._transport.sent, 4)
<24> self.assertEqual(server._transport.sent, 3)
<25>
<26> # check each endpoint has available connection IDs for the peer
<27> self.assertEqual(
<28> sequence_numbers(client._peer_cid_available), [1, 2, 3, 4, 5, 6, 7]
<29> )
<30> self.assertEqual(
<31> sequence_numbers(server._peer_cid_available), [1, 2, 3, 4, 5, 6, 7]
<32> )
<33>
<34> # clients sends data over stream
<35> client_reader, client_writer = run(client.create_stream())
<36> client_writer.write(b"ping")
<37>
<38> # client receives pong
<39> self.assertEqual(run(client_reader.read(1024)), b"pong")
<40>
<41> # client writes EOF
<42> client_writer.write_eof()
<43> run(asyncio.sleep(0))
<44> self.assertEqual(client._transport.sent, 7)</s>
|
===========below chunk 0===========
# module: tests.test_connection
class QuicConnectionTest(TestCase):
def _test_connect_with_version(self, client_versions, server_versions):
# offset: 1
===========unchanged ref 0===========
at: asyncio.tasks
ensure_future(coro_or_future: _FutureT[_T], *, loop: Optional[AbstractEventLoop]=...) -> Future[_T]
===========unchanged ref 1===========
gather(coro_or_future1: _FutureT[_T1], coro_or_future2: _FutureT[_T2], coro_or_future3: _FutureT[_T3], coro_or_future4: _FutureT[_T4], *, loop: Optional[AbstractEventLoop]=..., return_exceptions: bool=...) -> Future[
Tuple[Union[_T1, BaseException], Union[_T2, BaseException], Union[_T3, BaseException], Union[_T4, BaseException]]
]
gather(coro_or_future1: _FutureT[_T1], coro_or_future2: _FutureT[_T2], coro_or_future3: _FutureT[_T3], coro_or_future4: _FutureT[_T4], *, loop: Optional[AbstractEventLoop]=..., return_exceptions: Literal[False]=...) -> Future[Tuple[_T1, _T2, _T3, _T4]]
gather(coro_or_future1: _FutureT[_T1], coro_or_future2: _FutureT[_T2], *, loop: Optional[AbstractEventLoop]=..., return_exceptions: Literal[False]=...) -> Future[Tuple[_T1, _T2]]
gather(coro_or_future1: _FutureT[Any], coro_or_future2: _FutureT[Any], coro_or_future3: _FutureT[Any], coro_or_future4: _FutureT[Any], coro_or_future5: _FutureT[Any], coro_or_future6: _FutureT[Any], *coros_or_futures: _FutureT[Any], loop: Optional[AbstractEventLoop]=..., return_exceptions: bool=...) -> Future[List[Any]]
gather(coro_or_future1: _FutureT[_T1], coro_or_future2: _FutureT[_T2], coro_or_future3: _FutureT[_T3], *, loop: Optional[AbstractEventLoop]=..., return_exceptions: Literal[False]=...) -> Future[Tuple[_T1,</s>
===========unchanged ref 2===========
at: tests.test_connection
client_and_server(client_options={}, client_patch=lambda x: None, server_options={}, server_patch=lambda x: None, transport_options={})
sequence_numbers(connection_ids)
at: tests.utils
run(coro)
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/QuicConnectionTest.test_connect_with_log
|
Modified
|
aiortc~aioquic
|
788ac036d528d4ea24e361fe92b31c87046c1082
|
[tests] refactor some brittle tests
|
<7>:<del> self.assertEqual(client._transport.sent, 4)
<8>:<del> self.assertEqual(server._transport.sent, 3)
|
# module: tests.test_connection
class QuicConnectionTest(TestCase):
def test_connect_with_log(self):
<0> client_log_file = io.StringIO()
<1> server_log_file = io.StringIO()
<2> with client_and_server(
<3> client_options={"secrets_log_file": client_log_file},
<4> server_options={"secrets_log_file": server_log_file},
<5> ) as (client, server):
<6> run(client.wait_connected())
<7> self.assertEqual(client._transport.sent, 4)
<8> self.assertEqual(server._transport.sent, 3)
<9>
<10> # check secrets were logged
<11> client_log = client_log_file.getvalue()
<12> server_log = server_log_file.getvalue()
<13> self.assertEqual(client_log, server_log)
<14> labels = []
<15> for line in client_log.splitlines():
<16> labels.append(line.split()[0])
<17> self.assertEqual(
<18> labels,
<19> [
<20> "QUIC_SERVER_HANDSHAKE_TRAFFIC_SECRET",
<21> "QUIC_CLIENT_HANDSHAKE_TRAFFIC_SECRET",
<22> "QUIC_SERVER_TRAFFIC_SECRET_0",
<23> "QUIC_CLIENT_TRAFFIC_SECRET_0",
<24> ],
<25> )
<26>
|
===========unchanged ref 0===========
at: io
StringIO(initial_value: Optional[str]=..., newline: Optional[str]=...)
at: io.StringIO
getvalue(self) -> str
at: tests.test_connection
client_and_server(client_options={}, client_patch=lambda x: None, server_options={}, server_patch=lambda x: None, transport_options={})
at: tests.test_connection.QuicConnectionTest.test_connect_with_log
client_log_file = io.StringIO()
at: tests.utils
run(coro)
at: unittest.case.TestCase
assertEqual(first: Any, second: Any, msg: Any=...) -> None
===========changed ref 0===========
# module: tests.test_connection
class QuicConnectionTest(TestCase):
def _test_connect_with_version(self, client_versions, server_versions):
async def serve_request(reader, writer):
# check request
request = await reader.read(1024)
self.assertEqual(request, b"ping")
# send response
writer.write(b"pong")
- await asyncio.sleep(0)
# receives EOF
request = await reader.read()
self.assertEqual(request, b"")
+
+ # sends EOF
+ writer.write(b"done")
+ writer.write_eof()
with client_and_server(
client_options={"supported_versions": client_versions},
server_options={
"stream_handler": lambda reader, writer: asyncio.ensure_future(
serve_request(reader, writer)
),
"supported_versions": server_versions,
},
) as (client, server):
- run(client.wait_connected())
- self.assertEqual(client._transport.sent, 4)
- self.assertEqual(server._transport.sent, 3)
+ run(asyncio.gather(client.wait_connected(), server.wait_connected()))
# check each endpoint has available connection IDs for the peer
self.assertEqual(
sequence_numbers(client._peer_cid_available), [1, 2, 3, 4, 5, 6, 7]
- )
- self.assertEqual(
- sequence_numbers(server._peer_cid_available), [1, 2, 3, 4, 5, 6, 7]
)
# clients sends data over stream
client_reader, client_writer = run(client.create_stream())
client_writer.write(b"ping")
# client receives pong
self.assertEqual(run(client_reader.read(1024)), b"pong")
# client writes EOF
client_writer.write_eof()
- run(asyncio.sleep(0))</s>
===========changed ref 1===========
# module: tests.test_connection
class QuicConnectionTest(TestCase):
def _test_connect_with_version(self, client_versions, server_versions):
# offset: 1
<s>")
# client writes EOF
client_writer.write_eof()
- run(asyncio.sleep(0))
- self.assertEqual(client._transport.sent, 7)
- self.assertEqual(server._transport.sent, 6)
|
tests.test_connection/QuicConnectionTest.test_connection_lost
|
Modified
|
aiortc~aioquic
|
788ac036d528d4ea24e361fe92b31c87046c1082
|
[tests] refactor some brittle tests
|
<2>:<del> self.assertEqual(client._transport.sent, 4)
<3>:<del> self.assertEqual(server._transport.sent, 3)
<9>:<del> self.assertEqual(client._transport.sent, 5)
<10>:<del> self.assertEqual(server._transport.sent, 4)
|
# module: tests.test_connection
class QuicConnectionTest(TestCase):
def test_connection_lost(self):
<0> with client_and_server() as (client, server):
<1> run(client.wait_connected())
<2> self.assertEqual(client._transport.sent, 4)
<3> self.assertEqual(server._transport.sent, 3)
<4>
<5> # send data over stream
<6> client_reader, client_writer = run(client.create_stream())
<7> client_writer.write(b"ping")
<8> run(asyncio.sleep(0))
<9> self.assertEqual(client._transport.sent, 5)
<10> self.assertEqual(server._transport.sent, 4)
<11>
<12> # break connection
<13> client.connection_lost(None)
<14> self.assertEqual(run(client_reader.read()), b"")
<15>
|
===========unchanged ref 0===========
at: asyncio.tasks
sleep(delay: float, result: _T=..., *, loop: Optional[AbstractEventLoop]=...) -> Future[_T]
at: tests.test_connection
client_and_server(client_options={}, client_patch=lambda x: None, server_options={}, server_patch=lambda x: None, transport_options={})
at: tests.utils
run(coro)
at: unittest.case.TestCase
assertEqual(first: Any, second: Any, msg: Any=...) -> None
===========changed ref 0===========
# module: tests.test_connection
class QuicConnectionTest(TestCase):
def test_connect_with_log(self):
client_log_file = io.StringIO()
server_log_file = io.StringIO()
with client_and_server(
client_options={"secrets_log_file": client_log_file},
server_options={"secrets_log_file": server_log_file},
) as (client, server):
run(client.wait_connected())
- self.assertEqual(client._transport.sent, 4)
- self.assertEqual(server._transport.sent, 3)
# check secrets were logged
client_log = client_log_file.getvalue()
server_log = server_log_file.getvalue()
self.assertEqual(client_log, server_log)
labels = []
for line in client_log.splitlines():
labels.append(line.split()[0])
self.assertEqual(
labels,
[
"QUIC_SERVER_HANDSHAKE_TRAFFIC_SECRET",
"QUIC_CLIENT_HANDSHAKE_TRAFFIC_SECRET",
"QUIC_SERVER_TRAFFIC_SECRET_0",
"QUIC_CLIENT_TRAFFIC_SECRET_0",
],
)
===========changed ref 1===========
# module: tests.test_connection
class QuicConnectionTest(TestCase):
def _test_connect_with_version(self, client_versions, server_versions):
async def serve_request(reader, writer):
# check request
request = await reader.read(1024)
self.assertEqual(request, b"ping")
# send response
writer.write(b"pong")
- await asyncio.sleep(0)
# receives EOF
request = await reader.read()
self.assertEqual(request, b"")
+
+ # sends EOF
+ writer.write(b"done")
+ writer.write_eof()
with client_and_server(
client_options={"supported_versions": client_versions},
server_options={
"stream_handler": lambda reader, writer: asyncio.ensure_future(
serve_request(reader, writer)
),
"supported_versions": server_versions,
},
) as (client, server):
- run(client.wait_connected())
- self.assertEqual(client._transport.sent, 4)
- self.assertEqual(server._transport.sent, 3)
+ run(asyncio.gather(client.wait_connected(), server.wait_connected()))
# check each endpoint has available connection IDs for the peer
self.assertEqual(
sequence_numbers(client._peer_cid_available), [1, 2, 3, 4, 5, 6, 7]
- )
- self.assertEqual(
- sequence_numbers(server._peer_cid_available), [1, 2, 3, 4, 5, 6, 7]
)
# clients sends data over stream
client_reader, client_writer = run(client.create_stream())
client_writer.write(b"ping")
# client receives pong
self.assertEqual(run(client_reader.read(1024)), b"pong")
# client writes EOF
client_writer.write_eof()
- run(asyncio.sleep(0))</s>
===========changed ref 2===========
# module: tests.test_connection
class QuicConnectionTest(TestCase):
def _test_connect_with_version(self, client_versions, server_versions):
# offset: 1
<s>")
# client writes EOF
client_writer.write_eof()
- run(asyncio.sleep(0))
- self.assertEqual(client._transport.sent, 7)
- self.assertEqual(server._transport.sent, 6)
|
tests.test_connection/QuicConnectionTest.test_connection_lost_with_exception
|
Modified
|
aiortc~aioquic
|
788ac036d528d4ea24e361fe92b31c87046c1082
|
[tests] refactor some brittle tests
|
<2>:<del> self.assertEqual(client._transport.sent, 4)
<3>:<del> self.assertEqual(server._transport.sent, 3)
<9>:<del> self.assertEqual(client._transport.sent, 5)
<10>:<del> self.assertEqual(server._transport.sent, 4)
|
# module: tests.test_connection
class QuicConnectionTest(TestCase):
def test_connection_lost_with_exception(self):
<0> with client_and_server() as (client, server):
<1> run(client.wait_connected())
<2> self.assertEqual(client._transport.sent, 4)
<3> self.assertEqual(server._transport.sent, 3)
<4>
<5> # send data over stream
<6> client_reader, client_writer = run(client.create_stream())
<7> client_writer.write(b"ping")
<8> run(asyncio.sleep(0))
<9> self.assertEqual(client._transport.sent, 5)
<10> self.assertEqual(server._transport.sent, 4)
<11>
<12> # break connection
<13> exc = Exception("some error")
<14> client.connection_lost(exc)
<15> with self.assertRaises(Exception) as cm:
<16> run(client_reader.read())
<17> self.assertEqual(cm.exception, exc)
<18>
|
===========unchanged ref 0===========
at: tests.test_connection
client_and_server(client_options={}, client_patch=lambda x: None, server_options={}, server_patch=lambda x: None, transport_options={})
sequence_numbers(connection_ids)
at: tests.test_connection.QuicConnectionTest.test_connection_lost_with_exception
client_reader, client_writer = run(client.create_stream())
at: tests.utils
run(coro)
at: unittest.case.TestCase
assertEqual(first: Any, second: Any, msg: Any=...) -> None
assertRaises(expected_exception: Union[Type[_E], Tuple[Type[_E], ...]], msg: Any=...) -> _AssertRaisesContext[_E]
assertRaises(expected_exception: Union[Type[BaseException], Tuple[Type[BaseException], ...]], callable: Callable[..., Any], *args: Any, **kwargs: Any) -> None
at: unittest.case._AssertRaisesContext.__exit__
self.exception = exc_value.with_traceback(None)
===========changed ref 0===========
# module: tests.test_connection
class QuicConnectionTest(TestCase):
def test_connection_lost(self):
with client_and_server() as (client, server):
run(client.wait_connected())
- self.assertEqual(client._transport.sent, 4)
- self.assertEqual(server._transport.sent, 3)
# send data over stream
client_reader, client_writer = run(client.create_stream())
client_writer.write(b"ping")
run(asyncio.sleep(0))
- self.assertEqual(client._transport.sent, 5)
- self.assertEqual(server._transport.sent, 4)
# break connection
client.connection_lost(None)
self.assertEqual(run(client_reader.read()), b"")
===========changed ref 1===========
# module: tests.test_connection
class QuicConnectionTest(TestCase):
def test_connect_with_log(self):
client_log_file = io.StringIO()
server_log_file = io.StringIO()
with client_and_server(
client_options={"secrets_log_file": client_log_file},
server_options={"secrets_log_file": server_log_file},
) as (client, server):
run(client.wait_connected())
- self.assertEqual(client._transport.sent, 4)
- self.assertEqual(server._transport.sent, 3)
# check secrets were logged
client_log = client_log_file.getvalue()
server_log = server_log_file.getvalue()
self.assertEqual(client_log, server_log)
labels = []
for line in client_log.splitlines():
labels.append(line.split()[0])
self.assertEqual(
labels,
[
"QUIC_SERVER_HANDSHAKE_TRAFFIC_SECRET",
"QUIC_CLIENT_HANDSHAKE_TRAFFIC_SECRET",
"QUIC_SERVER_TRAFFIC_SECRET_0",
"QUIC_CLIENT_TRAFFIC_SECRET_0",
],
)
===========changed ref 2===========
# module: tests.test_connection
class QuicConnectionTest(TestCase):
def _test_connect_with_version(self, client_versions, server_versions):
async def serve_request(reader, writer):
# check request
request = await reader.read(1024)
self.assertEqual(request, b"ping")
# send response
writer.write(b"pong")
- await asyncio.sleep(0)
# receives EOF
request = await reader.read()
self.assertEqual(request, b"")
+
+ # sends EOF
+ writer.write(b"done")
+ writer.write_eof()
with client_and_server(
client_options={"supported_versions": client_versions},
server_options={
"stream_handler": lambda reader, writer: asyncio.ensure_future(
serve_request(reader, writer)
),
"supported_versions": server_versions,
},
) as (client, server):
- run(client.wait_connected())
- self.assertEqual(client._transport.sent, 4)
- self.assertEqual(server._transport.sent, 3)
+ run(asyncio.gather(client.wait_connected(), server.wait_connected()))
# check each endpoint has available connection IDs for the peer
self.assertEqual(
sequence_numbers(client._peer_cid_available), [1, 2, 3, 4, 5, 6, 7]
- )
- self.assertEqual(
- sequence_numbers(server._peer_cid_available), [1, 2, 3, 4, 5, 6, 7]
)
# clients sends data over stream
client_reader, client_writer = run(client.create_stream())
client_writer.write(b"ping")
# client receives pong
self.assertEqual(run(client_reader.read(1024)), b"pong")
# client writes EOF
client_writer.write_eof()
- run(asyncio.sleep(0))</s>
===========changed ref 3===========
# module: tests.test_connection
class QuicConnectionTest(TestCase):
def _test_connect_with_version(self, client_versions, server_versions):
# offset: 1
<s>")
# client writes EOF
client_writer.write_eof()
- run(asyncio.sleep(0))
- self.assertEqual(client._transport.sent, 7)
- self.assertEqual(server._transport.sent, 6)
|
tests.test_connection/QuicConnectionTest.test_create_stream_over_max_streams
|
Modified
|
aiortc~aioquic
|
788ac036d528d4ea24e361fe92b31c87046c1082
|
[tests] refactor some brittle tests
|
<2>:<del> self.assertEqual(client._transport.sent, 4)
<3>:<del> self.assertEqual(server._transport.sent, 3)
<8>:<del> self.assertEqual(client._transport.sent, 4)
<9>:<del> self.assertEqual(server._transport.sent, 3)
|
# module: tests.test_connection
class QuicConnectionTest(TestCase):
def test_create_stream_over_max_streams(self):
<0> with client_and_server() as (client, server):
<1> run(client.wait_connected())
<2> self.assertEqual(client._transport.sent, 4)
<3> self.assertEqual(server._transport.sent, 3)
<4>
<5> # create streams
<6> for i in range(128):
<7> client_reader, client_writer = run(client.create_stream())
<8> self.assertEqual(client._transport.sent, 4)
<9> self.assertEqual(server._transport.sent, 3)
<10>
<11> # create one too many
<12> with self.assertRaises(ValueError) as cm:
<13> client_reader, client_writer = run(client.create_stream())
<14> self.assertEqual(str(cm.exception), "Too many streams open")
<15>
|
===========unchanged ref 0===========
at: aioquic.packet
QuicErrorCode(x: Union[str, bytes, bytearray], base: int)
QuicErrorCode(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
at: aioquic.tls
Epoch()
CipherSuite(x: Union[str, bytes, bytearray], base: int)
CipherSuite(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
at: tests.test_connection
client_and_server(client_options={}, client_patch=lambda x: None, server_options={}, server_patch=lambda x: None, transport_options={})
at: tests.utils
run(coro)
===========changed ref 0===========
# module: tests.test_connection
class QuicConnectionTest(TestCase):
def test_connection_lost(self):
with client_and_server() as (client, server):
run(client.wait_connected())
- self.assertEqual(client._transport.sent, 4)
- self.assertEqual(server._transport.sent, 3)
# send data over stream
client_reader, client_writer = run(client.create_stream())
client_writer.write(b"ping")
run(asyncio.sleep(0))
- self.assertEqual(client._transport.sent, 5)
- self.assertEqual(server._transport.sent, 4)
# break connection
client.connection_lost(None)
self.assertEqual(run(client_reader.read()), b"")
===========changed ref 1===========
# module: tests.test_connection
class QuicConnectionTest(TestCase):
def test_connection_lost_with_exception(self):
with client_and_server() as (client, server):
run(client.wait_connected())
- self.assertEqual(client._transport.sent, 4)
- self.assertEqual(server._transport.sent, 3)
# send data over stream
client_reader, client_writer = run(client.create_stream())
client_writer.write(b"ping")
run(asyncio.sleep(0))
- self.assertEqual(client._transport.sent, 5)
- self.assertEqual(server._transport.sent, 4)
# break connection
exc = Exception("some error")
client.connection_lost(exc)
with self.assertRaises(Exception) as cm:
run(client_reader.read())
self.assertEqual(cm.exception, exc)
===========changed ref 2===========
# module: tests.test_connection
class QuicConnectionTest(TestCase):
def test_connect_with_log(self):
client_log_file = io.StringIO()
server_log_file = io.StringIO()
with client_and_server(
client_options={"secrets_log_file": client_log_file},
server_options={"secrets_log_file": server_log_file},
) as (client, server):
run(client.wait_connected())
- self.assertEqual(client._transport.sent, 4)
- self.assertEqual(server._transport.sent, 3)
# check secrets were logged
client_log = client_log_file.getvalue()
server_log = server_log_file.getvalue()
self.assertEqual(client_log, server_log)
labels = []
for line in client_log.splitlines():
labels.append(line.split()[0])
self.assertEqual(
labels,
[
"QUIC_SERVER_HANDSHAKE_TRAFFIC_SECRET",
"QUIC_CLIENT_HANDSHAKE_TRAFFIC_SECRET",
"QUIC_SERVER_TRAFFIC_SECRET_0",
"QUIC_CLIENT_TRAFFIC_SECRET_0",
],
)
===========changed ref 3===========
# module: tests.test_connection
class QuicConnectionTest(TestCase):
def _test_connect_with_version(self, client_versions, server_versions):
async def serve_request(reader, writer):
# check request
request = await reader.read(1024)
self.assertEqual(request, b"ping")
# send response
writer.write(b"pong")
- await asyncio.sleep(0)
# receives EOF
request = await reader.read()
self.assertEqual(request, b"")
+
+ # sends EOF
+ writer.write(b"done")
+ writer.write_eof()
with client_and_server(
client_options={"supported_versions": client_versions},
server_options={
"stream_handler": lambda reader, writer: asyncio.ensure_future(
serve_request(reader, writer)
),
"supported_versions": server_versions,
},
) as (client, server):
- run(client.wait_connected())
- self.assertEqual(client._transport.sent, 4)
- self.assertEqual(server._transport.sent, 3)
+ run(asyncio.gather(client.wait_connected(), server.wait_connected()))
# check each endpoint has available connection IDs for the peer
self.assertEqual(
sequence_numbers(client._peer_cid_available), [1, 2, 3, 4, 5, 6, 7]
- )
- self.assertEqual(
- sequence_numbers(server._peer_cid_available), [1, 2, 3, 4, 5, 6, 7]
)
# clients sends data over stream
client_reader, client_writer = run(client.create_stream())
client_writer.write(b"ping")
# client receives pong
self.assertEqual(run(client_reader.read(1024)), b"pong")
# client writes EOF
client_writer.write_eof()
- run(asyncio.sleep(0))</s>
===========changed ref 4===========
# module: tests.test_connection
class QuicConnectionTest(TestCase):
def _test_connect_with_version(self, client_versions, server_versions):
# offset: 1
<s>")
# client writes EOF
client_writer.write_eof()
- run(asyncio.sleep(0))
- self.assertEqual(client._transport.sent, 7)
- self.assertEqual(server._transport.sent, 6)
|
tests.test_connection/QuicConnectionTest.test_decryption_error
|
Modified
|
aiortc~aioquic
|
788ac036d528d4ea24e361fe92b31c87046c1082
|
[tests] refactor some brittle tests
|
<2>:<del> self.assertEqual(client._transport.sent, 4)
<3>:<del> self.assertEqual(server._transport.sent, 3)
<12>:<del> self.assertEqual(client._transport.sent, 4)
<13>:<del> self.assertEqual(server._transport.sent, 4)
<14>:<del> run(asyncio.sleep(0))
<15>:<add> run(server.wait_closed())
|
# module: tests.test_connection
class QuicConnectionTest(TestCase):
def test_decryption_error(self):
<0> with client_and_server() as (client, server):
<1> run(client.wait_connected())
<2> self.assertEqual(client._transport.sent, 4)
<3> self.assertEqual(server._transport.sent, 3)
<4>
<5> # mess with encryption key
<6> server._cryptos[tls.Epoch.ONE_RTT].send.setup(
<7> tls.CipherSuite.AES_128_GCM_SHA256, bytes(48)
<8> )
<9>
<10> # close
<11> server.close(error_code=QuicErrorCode.NO_ERROR)
<12> self.assertEqual(client._transport.sent, 4)
<13> self.assertEqual(server._transport.sent, 4)
<14> run(asyncio.sleep(0))
<15>
|
===========unchanged ref 0===========
at: aioquic.connection
QuicConnectionError(error_code: int, frame_type: int, reason_phrase: str)
at: aioquic.packet
QuicFrameType(x: Union[str, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc]=...)
QuicFrameType(x: Union[str, bytes, bytearray], base: int)
at: aioquic.tls
TLS_VERSION_1_3_DRAFT_28 = 0x7F1C
===========unchanged ref 1===========
at: asyncio.tasks
gather(coro_or_future1: _FutureT[_T1], coro_or_future2: _FutureT[_T2], coro_or_future3: _FutureT[_T3], coro_or_future4: _FutureT[_T4], *, loop: Optional[AbstractEventLoop]=..., return_exceptions: bool=...) -> Future[
Tuple[Union[_T1, BaseException], Union[_T2, BaseException], Union[_T3, BaseException], Union[_T4, BaseException]]
]
gather(coro_or_future1: _FutureT[_T1], coro_or_future2: _FutureT[_T2], coro_or_future3: _FutureT[_T3], coro_or_future4: _FutureT[_T4], *, loop: Optional[AbstractEventLoop]=..., return_exceptions: Literal[False]=...) -> Future[Tuple[_T1, _T2, _T3, _T4]]
gather(coro_or_future1: _FutureT[_T1], coro_or_future2: _FutureT[_T2], *, loop: Optional[AbstractEventLoop]=..., return_exceptions: Literal[False]=...) -> Future[Tuple[_T1, _T2]]
gather(coro_or_future1: _FutureT[Any], coro_or_future2: _FutureT[Any], coro_or_future3: _FutureT[Any], coro_or_future4: _FutureT[Any], coro_or_future5: _FutureT[Any], coro_or_future6: _FutureT[Any], *coros_or_futures: _FutureT[Any], loop: Optional[AbstractEventLoop]=..., return_exceptions: bool=...) -> Future[List[Any]]
gather(coro_or_future1: _FutureT[_T1], coro_or_future2: _FutureT[_T2], coro_or_future3: _FutureT[_T3], *, loop: Optional[AbstractEventLoop]=..., return_exceptions: Literal[False]=...) -> Future[</s>
===========unchanged ref 2===========
at: tests.test_connection
client_and_server(client_options={}, client_patch=lambda x: None, server_options={}, server_patch=lambda x: None, transport_options={})
at: tests.test_connection.QuicConnectionTest.test_tls_error
patch(client)
at: tests.utils
run(coro)
at: unittest.case.TestCase
assertEqual(first: Any, second: Any, msg: Any=...) -> None
assertRaises(expected_exception: Union[Type[_E], Tuple[Type[_E], ...]], msg: Any=...) -> _AssertRaisesContext[_E]
assertRaises(expected_exception: Union[Type[BaseException], Tuple[Type[BaseException], ...]], callable: Callable[..., Any], *args: Any, **kwargs: Any) -> None
at: unittest.case._AssertRaisesContext.__exit__
self.exception = exc_value.with_traceback(None)
===========changed ref 0===========
# module: tests.test_connection
class QuicConnectionTest(TestCase):
def test_create_stream_over_max_streams(self):
with client_and_server() as (client, server):
run(client.wait_connected())
- self.assertEqual(client._transport.sent, 4)
- self.assertEqual(server._transport.sent, 3)
# create streams
for i in range(128):
client_reader, client_writer = run(client.create_stream())
- self.assertEqual(client._transport.sent, 4)
- self.assertEqual(server._transport.sent, 3)
# create one too many
with self.assertRaises(ValueError) as cm:
client_reader, client_writer = run(client.create_stream())
self.assertEqual(str(cm.exception), "Too many streams open")
===========changed ref 1===========
# module: tests.test_connection
class QuicConnectionTest(TestCase):
def test_connection_lost(self):
with client_and_server() as (client, server):
run(client.wait_connected())
- self.assertEqual(client._transport.sent, 4)
- self.assertEqual(server._transport.sent, 3)
# send data over stream
client_reader, client_writer = run(client.create_stream())
client_writer.write(b"ping")
run(asyncio.sleep(0))
- self.assertEqual(client._transport.sent, 5)
- self.assertEqual(server._transport.sent, 4)
# break connection
client.connection_lost(None)
self.assertEqual(run(client_reader.read()), b"")
===========changed ref 2===========
# module: tests.test_connection
class QuicConnectionTest(TestCase):
def test_connection_lost_with_exception(self):
with client_and_server() as (client, server):
run(client.wait_connected())
- self.assertEqual(client._transport.sent, 4)
- self.assertEqual(server._transport.sent, 3)
# send data over stream
client_reader, client_writer = run(client.create_stream())
client_writer.write(b"ping")
run(asyncio.sleep(0))
- self.assertEqual(client._transport.sent, 5)
- self.assertEqual(server._transport.sent, 4)
# break connection
exc = Exception("some error")
client.connection_lost(exc)
with self.assertRaises(Exception) as cm:
run(client_reader.read())
self.assertEqual(cm.exception, exc)
===========changed ref 3===========
# module: tests.test_connection
class QuicConnectionTest(TestCase):
def test_connect_with_log(self):
client_log_file = io.StringIO()
server_log_file = io.StringIO()
with client_and_server(
client_options={"secrets_log_file": client_log_file},
server_options={"secrets_log_file": server_log_file},
) as (client, server):
run(client.wait_connected())
- self.assertEqual(client._transport.sent, 4)
- self.assertEqual(server._transport.sent, 3)
# check secrets were logged
client_log = client_log_file.getvalue()
server_log = server_log_file.getvalue()
self.assertEqual(client_log, server_log)
labels = []
for line in client_log.splitlines():
labels.append(line.split()[0])
self.assertEqual(
labels,
[
"QUIC_SERVER_HANDSHAKE_TRAFFIC_SECRET",
"QUIC_CLIENT_HANDSHAKE_TRAFFIC_SECRET",
"QUIC_SERVER_TRAFFIC_SECRET_0",
"QUIC_CLIENT_TRAFFIC_SECRET_0",
],
)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.