SiteManagerPlugin.py 文件源码

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

项目:zeronet-debian 作者: bashrc 项目源码 文件源码
def resolveDomainDnschainNet(self, domain):
        try:
            match = self.isDomain(domain)
            sub_domain = match.group(1).strip(".")
            top_domain = match.group(2)
            if not sub_domain: sub_domain = "@"
            address = None
            with gevent.Timeout(5, Exception("Timeout: 5s")):
                res = Http.get("https://api.dnschain.net/v1/namecoin/key/%s" % top_domain).read()
                data = json.loads(res)["data"]["value"]
                if "zeronet" in data:
                    for key, val in data["zeronet"].iteritems():
                        self.dns_cache[key+"."+top_domain] = [val, time.time()+60*60*5] # Cache for 5 hours
                    self.saveDnsCache()
                    return data["zeronet"].get(sub_domain)
            # Not found
            return address
        except Exception, err:
            log.debug("Dnschain.net %s resolve error: %s" % (domain, Debug.formatException(err)))


    # Resolve domain using dnschain.info
    # Return: The address or None
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号