MCPcopy Create free account
hub / github.com/rthalley/dnspython / from_wire_parser

Function from_wire_parser

dns/name.py:1075–1105  ·  view source on GitHub ↗

Convert possibly compressed wire format into a Name. *parser* is a dns.wire.Parser. Raises ``dns.name.BadPointer`` if a compression pointer did not point backwards in the message. Raises ``dns.name.BadLabelType`` if an invalid label type was encountered. Returns a ``dns.name.

(parser: "dns.wire.Parser")

Source from the content-addressed store, hash-verified

1073
1074
1075def from_wire_parser(parser: "dns.wire.Parser") -> Name:
1076 """Convert possibly compressed wire format into a Name.
1077
1078 *parser* is a dns.wire.Parser.
1079
1080 Raises ``dns.name.BadPointer`` if a compression pointer did not
1081 point backwards in the message.
1082
1083 Raises ``dns.name.BadLabelType`` if an invalid label type was encountered.
1084
1085 Returns a ``dns.name.Name``
1086 """
1087
1088 labels = []
1089 biggest_pointer = parser.current
1090 with parser.restore_furthest():
1091 count = parser.get_uint8()
1092 while count != 0:
1093 if count < 64:
1094 labels.append(parser.get_bytes(count))
1095 elif count >= 192:
1096 current = (count & 0x3F) * 256 + parser.get_uint8()
1097 if current >= biggest_pointer:
1098 raise BadPointer
1099 biggest_pointer = current
1100 parser.seek(current)
1101 else:
1102 raise BadLabelType
1103 count = parser.get_uint8()
1104 labels.append(b"")
1105 return Name(labels)
1106
1107
1108def from_wire(message: bytes, current: int) -> Tuple[Name, int]:

Callers 1

from_wireFunction · 0.70

Calls 5

NameClass · 0.85
restore_furthestMethod · 0.80
get_bytesMethod · 0.80
get_uint8Method · 0.45
seekMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…