MCPcopy
hub / github.com/shadowsocks/shadowsocks / parse_record

Function parse_record

shadowsocks/asyncdns.py:151–164  ·  view source on GitHub ↗
(data, offset, question=False)

Source from the content-addressed store, hash-verified

149# / /
150# +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
151def parse_record(data, offset, question=False):
152 nlen, name = parse_name(data, offset)
153 if not question:
154 record_type, record_class, record_ttl, record_rdlength = struct.unpack(
155 '!HHiH', data[offset + nlen:offset + nlen + 10]
156 )
157 ip = parse_ip(record_type, data, record_rdlength, offset + nlen + 10)
158 return nlen + 10 + record_rdlength, \
159 (name, ip, record_type, record_class, record_ttl)
160 else:
161 record_type, record_class = struct.unpack(
162 '!HH', data[offset + nlen:offset + nlen + 4]
163 )
164 return nlen + 4, (name, None, record_type, record_class, None, None)
165
166
167def parse_header(data):

Callers 1

parse_responseFunction · 0.85

Calls 2

parse_nameFunction · 0.85
parse_ipFunction · 0.85

Tested by

no test coverage detected