1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

selftest: allow dns_hub.py to do forwarding to ipv6 servers

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
This commit is contained in:
Stefan Metzmacher 2020-03-11 17:09:13 +01:00 committed by Andreas Schneider
parent 25ba290d18
commit ffa40fa90f

View File

@ -58,11 +58,18 @@ class DnsHandler(sserver.BaseRequestHandler):
def dns_transaction_udp(self, packet, host):
"send a DNS query and read the reply"
s = None
flags = socket.AddressInfo.AI_NUMERICHOST
flags |= socket.AddressInfo.AI_NUMERICSERV
flags |= socket.AddressInfo.AI_PASSIVE
addr_info = socket.getaddrinfo(host, int(53),
type=socket.SocketKind.SOCK_DGRAM,
flags=flags)
assert len(addr_info) == 1
try:
send_packet = ndr.ndr_pack(packet)
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, 0)
s = socket.socket(addr_info[0][0], addr_info[0][1], 0)
s.settimeout(DNS_REQUEST_TIMEOUT)
s.connect((host, 53))
s.connect(addr_info[0][4])
s.sendall(send_packet, 0)
recv_packet = s.recv(2048, 0)
return ndr.ndr_unpack(dns.name_packet, recv_packet)