# # client type user of rfc1035.py # # this violates all sorts of good practices, but it works as a demo # import rfc1035 ## ## Some sample objects. ## import socket, rfc1035 # dns = rfc1035 sample = dns.A_RR() sample.name = ('reason', 'omnigroup', 'com') sample.rrclass = 'IN' sample.TTL = 7 sample.address = (198,151,161,25) # # # UDPPort = 53 maxUDPlen = 512 def transact(request, host): message = request.encode() s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.sendto(message, (host, UDPPort)) (reply, sender) = s.recvfrom(maxUDPlen) print 'reply from', sender decoded = dns.DNSMessage(reply) return decoded # def inquire(question, host): req = dns.DNSMessage() req.qdrecs.append(question) req.id = 42 reply = transact(req, host) reply.__print__() return reply.anrecs # def addrquery(addr, *host): if host: host = host[0] else: host = '100.0.0.8' question = dns.Question() question.name = string.splitfields(addr, '.') question.rrclass = '*' question.type = 'A' return inquire(question, host) #