Пример #1
0
	def __init__(self, data, packet_s, names):
		if data.startswith('\0'):
			name = '.'
			ptr = None
			total_read = 1
		else:
			name, ptr = convert.dns_string(data)
			total_read = len(name) + 2

		if ptr is not None:
			parts = [name] if name else []
			extra = convert.dns_to_string(packet_s[ptr:], packet_s)

			if extra is not None:
				parts += [extra] if extra else []
				name = '.'.join(parts)
			else:
				name = None

		if name:
			data = data[total_read:]
			rdata_len = convert.u16(data[8:10])
			ok = len(data) >= 10 + rdata_len
		else:
			rdata_len = None
			ok = False

		self.question = name if ok else None
		self.querytype = convert.u16(data[:2]) if ok else None
		self.queryclass = convert.u16(data[2:4]) if ok else None
		self.ttl = convert.u32(data[4:8]) if ok else None
		self.rdata = data[10:10+rdata_len] if ok else None
		self._len = (total_read + 10 + rdata_len) if ok else None
Пример #2
0
    def __init__(self, data, packet_s, names):
        if data.startswith('\0'):
            name = '.'
            ptr = None
            total_read = 1
        else:
            name, ptr = convert.dns_string(data)
            total_read = len(name) + 2

        if ptr is not None:
            parts = [name] if name else []
            extra = convert.dns_to_string(packet_s[ptr:], packet_s)

            if extra is not None:
                parts += [extra] if extra else []
                name = '.'.join(parts)
            else:
                name = None

        if name:
            data = data[total_read:]
            rdata_len = convert.u16(data[8:10])
            ok = len(data) >= 10 + rdata_len
        else:
            rdata_len = None
            ok = False

        self.question = name if ok else None
        self.querytype = convert.u16(data[:2]) if ok else None
        self.queryclass = convert.u16(data[2:4]) if ok else None
        self.ttl = convert.u32(data[4:8]) if ok else None
        self.rdata = data[10:10 + rdata_len] if ok else None
        self._len = (total_read + 10 + rdata_len) if ok else None
Пример #3
0
	def __init__(self, data, packet_s, names):
		if data.startswith('\0'):
			name = '.'
			ptr = None
			total_read = 1
		else:
			total_read, name = convert.dns_to_string_info(data, packet_s)

		if name:
			data = data[total_read:]
			rdata_len = convert.u16(data[8:10])
			ok = len(data) >= 10 + rdata_len
		else:
			rdata_len = None
			ok = False

		self.question = name if ok else None
		self.querytype = convert.u16(data[:2]) if ok else None
		self.queryclass = convert.u16(data[2:4]) if ok else None
		self.ttl = convert.u32(data[4:8]) if ok else None
		self.rdata = data[10:10+rdata_len] if ok else None
		self._len = (total_read + 10 + rdata_len) if ok else None