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

Method from_wire_parser

dns/edns.py:312–327  ·  view source on GitHub ↗
(
        cls, otype: OptionType | str, parser: "dns.wire.Parser"
    )

Source from the content-addressed store, hash-verified

310
311 @classmethod
312 def from_wire_parser(
313 cls, otype: OptionType | str, parser: "dns.wire.Parser"
314 ) -> Option:
315 family, src, scope = parser.get_struct("!HBB")
316 addrlen = int(math.ceil(src / 8.0))
317 prefix = parser.get_bytes(addrlen)
318 if family == 1:
319 pad = 4 - addrlen
320 addr = dns.ipv4.inet_ntoa(prefix + b"\x00" * pad)
321 elif family == 2:
322 pad = 16 - addrlen
323 addr = dns.ipv6.inet_ntoa(prefix + b"\x00" * pad)
324 else:
325 raise ValueError("unsupported family")
326
327 return cls(addr, src, scope)
328
329
330class EDECode(dns.enum.IntEnum):

Callers

nothing calls this directly

Calls 2

get_structMethod · 0.80
get_bytesMethod · 0.80

Tested by

no test coverage detected