def resolve(self,request,handler): if handler.protocol == 'udp': proxy_r = request.send(self.address,self.port) else: proxy_r = request.send(self.address,self.port,tcp=True) reply = DNSRecord.parse(proxy_r) return reply
def resolve(self, request, handler): if handler.protocol == 'udp': proxy_r = request.send(self.address, self.port) else: proxy_r = request.send(self.address, self.port, tcp=True) reply = DNSRecord.parse(proxy_r) return reply
def get_reply(self, data): host, port = self.server.resolver.address, self.server.resolver.port request = DNSRecord.parse(data) self.log_request(request) if self.protocol == 'tcp': data = struct.pack("!H", len(data)) + data response = send_tcp(data, host, port) response = response[2:] else: response = send_udp(data, host, port) reply = DNSRecord.parse(response) self.log_reply(reply) return response
def get_reply(self,data): host,port = self.server.resolver.address,self.server.resolver.port request = DNSRecord.parse(data) self.log_request(request) if self.protocol == 'tcp': data = struct.pack("!H",len(data)) + data response = send_tcp(data,host,port) response = response[2:] else: response = send_udp(data,host,port) reply = DNSRecord.parse(response) self.log_reply(reply) return response
def get_reply(self,data): request = DNSRecord.parse(data) self.server.logger.log_request(self,request) resolver = self.server.resolver reply = resolver.resolve(request,self) self.server.logger.log_reply(self,reply) if self.protocol == 'udp': rdata = reply.pack() if self.udplen and len(rdata) > self.udplen: truncated_reply = reply.truncate() rdata = truncated_reply.pack() self.server.logger.log_truncated(self,truncated_reply) else: rdata = reply.pack() return rdata
def get_reply(self, data): request = DNSRecord.parse(data) self.server.logger.log_request(self, request) resolver = self.server.resolver reply = resolver.resolve(request, self) self.server.logger.log_reply(self, reply) if self.protocol == 'udp': rdata = reply.pack() if self.udplen and len(rdata) > self.udplen: truncated_reply = reply.truncate() rdata = truncated_reply.pack() self.server.logger.log_truncated(self, truncated_reply) else: rdata = reply.pack() return rdata
def resolve(self,request,handler): reply = request.reply() qname = request.q.qname qtype = QTYPE[request.q.qtype] # Try to resolve locally unless on skip list if not any([qname.matchGlob(s) for s in self.skip]): for name,rtype,rr in self.zone: if qname.matchGlob(name) and (qtype in (rtype,'ANY','CNAME')): a = copy.copy(rr) a.rname = qname reply.add_answer(a) # Check for NXDOMAIN if any([qname.matchGlob(s) for s in self.nxdomain]): reply.header.rcode = getattr(RCODE,'NXDOMAIN') return reply # Otherwise proxy if not reply.rr: if handler.protocol == 'udp': proxy_r = request.send(self.address,self.port) else: proxy_r = request.send(self.address,self.port,tcp=True) reply = DNSRecord.parse(proxy_r) return reply
def resolve(self, request, handler): reply = request.reply() qname = request.q.qname qtype = QTYPE[request.q.qtype] # Try to resolve locally unless on skip list if not any([qname.matchGlob(s) for s in self.skip]): for name, rtype, rr in self.zone: if qname.matchGlob(name) and (qtype in (rtype, 'ANY', 'CNAME')): a = copy.copy(rr) a.rname = qname reply.add_answer(a) # Check for NXDOMAIN if any([qname.matchGlob(s) for s in self.nxdomain]): reply.header.rcode = getattr(RCODE, 'NXDOMAIN') return reply # Otherwise proxy if not reply.rr: if handler.protocol == 'udp': proxy_r = request.send(self.address, self.port) else: proxy_r = request.send(self.address, self.port, tcp=True) reply = DNSRecord.parse(proxy_r) return reply