MCPcopy
hub / github.com/shadowsocks/shadowsocks / parse_header

Function parse_header

shadowsocks/asyncdns.py:167–183  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

165
166
167def parse_header(data):
168 if len(data) >= 12:
169 header = struct.unpack('!HBBHHHH', data[:12])
170 res_id = header[0]
171 res_qr = header[1] & 128
172 res_tc = header[1] & 2
173 res_ra = header[2] & 128
174 res_rcode = header[2] & 15
175 # assert res_tc == 0
176 # assert res_rcode in [0, 3]
177 res_qdcount = header[3]
178 res_ancount = header[4]
179 res_nscount = header[5]
180 res_arcount = header[6]
181 return (res_id, res_qr, res_tc, res_ra, res_rcode, res_qdcount,
182 res_ancount, res_nscount, res_arcount)
183 return None
184
185
186def parse_response(data):

Callers 1

parse_responseFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected