def resolve(self,request,handler):
reply = request.reply()
qname = request.q.qname
qtype = QTYPE[request.q.qtype]
if qname.matchGlob("api-*padsv.gungho.jp."):
config = wx.ConfigBase.Get()
host = config.Read("host") or socket.gethostbyname(socket.gethostname())
reply.add_answer(RR(qname,QTYPE.A,rdata=A(host)))
evt = custom_events.wxStatusEvent(message="Got DNS Request")
wx.PostEvent(self.status_ctrl,evt)
evt = custom_events.wxDNSEvent(message=str(qname)[:-1])
wx.PostEvent(self.main_frame,evt)
time.sleep(0.5) # we need to sleep until the proxy is up, half a second should do it...
# 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
评论列表
文章目录