Unpacks HTTPS RDATA from byte data. Raises: struct.error if the record is malformed.
(data: bytes)
| 92 | |
| 93 | |
| 94 | def unpack(data: bytes) -> HTTPSRecord: |
| 95 | """ |
| 96 | Unpacks HTTPS RDATA from byte data. |
| 97 | |
| 98 | Raises: |
| 99 | struct.error if the record is malformed. |
| 100 | """ |
| 101 | offset = 0 |
| 102 | |
| 103 | # Priority (2 bytes) |
| 104 | priority = struct.unpack("!h", data[offset : offset + 2])[0] |
| 105 | offset += 2 |
| 106 | |
| 107 | # TargetName (variable length) |
| 108 | target_name, offset = domain_names.unpack_from(data, offset) |
| 109 | |
| 110 | # Service Parameters (remaining bytes) |
| 111 | params = _unpack_params(data, offset) |
| 112 | |
| 113 | return HTTPSRecord(priority=priority, target_name=target_name, params=params) |
| 114 | |
| 115 | |
| 116 | def _pack_params(params: dict[int, bytes]) -> bytes: |
nothing calls this directly
no test coverage detected
searching dependent graphs…