blob: 8f4e2f3d9f0f23f6cf47a3482619877f953ac692 [file] [log] [blame]
DR695Hc9392aa2019-05-24 16:23:44 -04001import dns.message
2import dns.name
3import dns.query
4from robot.api.deco import keyword
5
6
7class DNSKeywords(object):
8 """ Utilities useful for DNS requests """
9
10 def __init__(self):
11 super(DNSKeywords, self).__init__()
12
13 @keyword
14 def dns_request(self, domain, ns):
15 """ return the ip address of the given domain name from the given nameserver """
16 request = dns.message.make_query(domain, dns.rdatatype.A)
17 request.flags |= dns.flags.AD
18 request.find_rrset(request.additional, dns.name.root, 65535, dns.rdatatype.OPT, create=True, force_unique=True)
19 response = dns.query.udp(request, ns)
20
21 for answer in response.answer:
22 for item in answer.items:
23 return item