示例#1
0
        def _check_ip(self, params):
            session = self.get_session()

            if session is None:
                self.send_response(httplib.UNAUTHORIZED)
                self.send_header(HTTP_HEADER.CONNECTION, "close")
                return None

            self.send_response(httplib.OK)
            self.send_header(HTTP_HEADER.CONNECTION, "close")
            self.send_header(HTTP_HEADER.CONTENT_TYPE, "text/plain")

            try:
                result_worst = worst_asns(params.get("address"))
                if result_worst:
                    result_ipcat = result_worst
                else:
                    _ = (ipcat_lookup(params.get("address"))
                         or "").lower().split(' ')
                    result_ipcat = _[1] if _[0] == 'the' else _[0]
                return ("%s" if not params.get("callback") else "%s(%%s)" %
                        params.get("callback")) % json.dumps({
                            "ipcat":
                            result_ipcat,
                            "worst_asns":
                            str(result_worst is not None).lower()
                        })
            except:
                if config.SHOW_DEBUG:
                    traceback.print_exc()
示例#2
0
        def _check_ip(self, params):
            session = self.get_session()

            if session is None:
                self.send_response(httplib.UNAUTHORIZED)
                self.send_header(HTTP_HEADER.CONNECTION, "close")
                return None

            self.send_response(httplib.OK)
            self.send_header(HTTP_HEADER.CONNECTION, "close")
            self.send_header(HTTP_HEADER.CONTENT_TYPE, "text/plain")

            try:
                result_worst = worst_asns(params.get("address"))
                if result_worst:
                    result_ipcat = result_worst
                else:
                    _ = (ipcat_lookup(params.get("address")) or "").lower().split(" ")
                    result_ipcat = _[1] if _[0] == "the" else _[0]
                return ("%s" if not params.get("callback") else "%s(%%s)" % params.get("callback")) % json.dumps(
                    {"ipcat": result_ipcat, "worst_asns": str(result_worst is not None).lower()}
                )
            except:
                if config.SHOW_DEBUG:
                    traceback.print_exc()
示例#3
0
        def _ipcat(self, params):
            session = self.get_session()

            if session is None:
                self.send_response(httplib.UNAUTHORIZED)
                self.send_header("Connection", "close")
                return None

            self.send_response(httplib.OK)
            self.send_header("Connection", "close")
            self.send_header("Content-Type", "text/plain")

            try:
                return (ipcat_lookup(params.get("address")) or "").lower().split(' ')[0]
            except:
                if config.SHOW_DEBUG:
                    traceback.print_exc()
        def _ipcat(self, params):
            session = self.get_session()

            if session is None:
                self.send_response(httplib.UNAUTHORIZED)
                self.send_header("Connection", "close")
                return None

            self.send_response(httplib.OK)
            self.send_header("Connection", "close")
            self.send_header("Content-Type", "text/plain")

            try:
                return (ipcat_lookup(params.get("address"))
                        or "").lower().split(' ')[0]
            except:
                if config.SHOW_DEBUG:
                    traceback.print_exc()
示例#5
0
        def _check_ip(self, params):
            session = self.get_session()

            if session is None:
                self.send_response(httplib.UNAUTHORIZED)
                self.send_header("Connection", "close")
                return None

            self.send_response(httplib.OK)
            self.send_header("Connection", "close")
            self.send_header("Content-Type", "text/plain")

            try:
                _ = worst_asns(params.get("address"))
                return ("%s" if not params.get("callback") else "%s(%%s)" %
                        params.get("callback")) % json.dumps({
                            "ipcat": (_ or ipcat_lookup(params.get("address"))
                                      or "").lower().split(' ')[0],
                            "worst_asns":
                            str(_ is not None).lower()
                        })
            except:
                if config.SHOW_DEBUG:
                    traceback.print_exc()