dnsproxy.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:padherder_proxy 作者: jgoldshlag 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号