예제 #1
0
    def lookup(self, asn):
        try:
            asn = int(asn)
        except ValueError:
            idiokit.stop(())

        results = self._cache.get(asn, None)
        if results is not None:
            idiokit.stop(results)

        try:
            txt_results = yield dns.txt("AS{0}.asn.cymru.com".format(asn),
                                        resolver=self._resolver)
        except dns.DNSError:
            idiokit.stop(())

        results = _split(txt_results, self._keys)
        self._cache.set(asn, results)
        idiokit.stop(results)
예제 #2
0
    def lookup(self, asn):
        try:
            asn = int(asn)
        except ValueError:
            idiokit.stop(())

        results = self._cache.get(asn, None)
        if results is not None:
            idiokit.stop(results)

        try:
            txt_results = yield dns.txt(
                "AS{0}.asn.cymru.com".format(asn),
                resolver=self._resolver)
        except dns.DNSError:
            idiokit.stop(())

        results = _split(txt_results, self._keys)
        self._cache.set(asn, results)
        idiokit.stop(results)
예제 #3
0
    def _lookup(self, cache_key, query):
        results = self._cache.get(cache_key, None)
        if results is not None:
            idiokit.stop(results)

        try:
            txt_results = yield dns.txt(query, resolver=self._resolver)
        except dns.DNSError:
            idiokit.stop(())

        results = []
        for result in _split(txt_results, self._keys):
            result_dict = dict(result)
            for asn in result_dict.get("asn", "").split():
                if not asn:
                    continue
                result_dict["asn"] = asn
                results.append(tuple(result_dict.iteritems()))

        self._cache.set(cache_key, tuple(results))
        idiokit.stop(results)
예제 #4
0
    def _lookup(self, cache_key, query):
        results = self._cache.get(cache_key, None)
        if results is not None:
            idiokit.stop(results)

        try:
            txt_results = yield dns.txt(query, resolver=self._resolver)
        except dns.DNSError:
            idiokit.stop(())

        results = []
        for result in _split(txt_results, self._keys):
            result_dict = dict(result)
            for asn in result_dict.get("asn", "").split():
                if not asn:
                    continue
                result_dict["asn"] = asn
                results.append(tuple(result_dict.iteritems()))

        self._cache.set(cache_key, tuple(results))
        idiokit.stop(results)