def t1(): content, status, response = front.request("GET", "scan1.xx-net.net", timeout=1000) print status del response content, status, response = front.request("GET", "scan1.xx-net.net", timeout=1000) print status front.stop()
def get(): start_time = time.time() content, status, response = front.request("GET", "dns.xx-net.net", path="/query?domain=www.google.com") time_cost = time.time() - start_time xlog.info("GET cost:%f", time_cost) xlog.info("status:%d content:%s", status, content) front.stop()
def main(): content, status, response = front.request("GET", "center.xx-net.net", "/", timeout=10) print("status:%d" % status) print("content:%s" % content) while connect_control.keep_running: time.sleep(1)
def get(): start_time = time.time() content, status, response = front.request("GET", "dns.xx-net.com", path="/query?domain=www.google.com") time_cost = time.time() - start_time xlog.info("GET cost:%f", time_cost) xlog.info("status:%d content:%s", status, content) front.stop()
def get(): start_time = time.time() content, status, response = front.request("GET", "center.xx-net.net", "/", timeout=10) time_cost = time.time() - start_time xlog.info("GET cost:%f", time_cost) xlog.info("status:%d content:%s", status, content) front.stop()
def request_gae_server(headers, body, url, timeout): # process on http protocol # process status code return by http server # raise error, let up layer retry. try: response = front.request("POST", None, "/_gh/", headers, body, timeout) if not response: raise GAE_Exception(600, "fetch gae fail") if response.status >= 600: raise GAE_Exception(response.status, "fetch gae fail:%d" % response.status) appid = response.ssl_sock.host.split(".")[0] if response.status == 404: # logger.warning('APPID %r not exists, remove it.', response.ssl_sock.appid) front.appid_manager.report_not_exist(appid, response.ssl_sock.ip) # google_ip.report_connect_closed(response.ssl_sock.ip, "appid not exist") response.worker.close("appid not exist:%s" % appid) raise GAE_Exception(603, "appid not exist %s" % appid) if response.status == 503: logger.warning('APPID %r out of Quota, remove it. %s', appid, response.ssl_sock.ip) front.appid_manager.report_out_of_quota(appid) # google_ip.report_connect_closed(response.ssl_sock.ip, "out of quota") response.worker.close("appid out of quota:%s" % appid) raise GAE_Exception(604, "appid out of quota:%s" % appid) server_type = response.getheader("server", "") # content_type = response.getheaders("content-type", "") if ("gws" not in server_type and "Google Frontend" not in server_type and "GFE" not in server_type) or \ response.status == 403 or response.status == 405: # some ip can connect, and server type can be gws # but can't use as GAE server # so we need remove it immediately logger.warn("IP:%s not support GAE, headers:%s status:%d", response.ssl_sock.ip, response.headers, response.status) response.worker.close("ip not support GAE") raise GAE_Exception(602, "ip not support GAE") response.gps = response.getheader("x-server", "") if response.status > 300: raise GAE_Exception(605, "status:%d" % response.status) if response.status != 200: logger.warn("GAE %s appid:%s status:%d", response.ssl_sock.ip, appid, response.status) return response except GAE_Exception as e: if e.error_code not in (600, 603, 604): front.ip_manager.recheck_ip(response.ssl_sock.ip, first_report=False)
def request_gae_server(headers, body, url, timeout): # process on http protocol # process status code return by http server # raise error, let up layer retry. try: response = front.request("POST", None, "/_gh/", headers, body, timeout) if not response: raise GAE_Exception(600, "fetch gae fail") if response.status >= 600: raise GAE_Exception( response.status, "fetch gae fail:%d" % response.status) appid = response.ssl_sock.host.split(".")[0] if response.status == 404: # xlog.warning('APPID %r not exists, remove it.', response.ssl_sock.appid) front.appid_manager.report_not_exist( appid, response.ssl_sock.ip) # google_ip.report_connect_closed(response.ssl_sock.ip, "appid not exist") response.worker.close("appid not exist:%s" % appid) raise GAE_Exception(603, "appid not exist %s" % appid) if response.status == 503: xlog.warning('APPID %r out of Quota, remove it. %s', appid, response.ssl_sock.ip) front.appid_manager.report_out_of_quota(appid) # google_ip.report_connect_closed(response.ssl_sock.ip, "out of quota") response.worker.close("appid out of quota:%s" % appid) raise GAE_Exception(604, "appid out of quota:%s" % appid) server_type = response.getheader("server", "") # content_type = response.getheaders("content-type", "") if ("gws" not in server_type and "Google Frontend" not in server_type and "GFE" not in server_type) or \ response.status == 403 or response.status == 405: # some ip can connect, and server type can be gws # but can't use as GAE server # so we need remove it immediately xlog.warn("IP:%s not support GAE, headers:%s status:%d", response.ssl_sock.ip, response.headers, response.status) response.worker.close("ip not support GAE") raise GAE_Exception(602, "ip not support GAE") response.gps = response.getheader("x-server", "") if response.status > 300: raise GAE_Exception(605, "status:%d" % response.status) if response.status != 200: xlog.warn("GAE %s appid:%s status:%d", response.ssl_sock.ip, appid, response.status) return response except GAE_Exception as e: if e.error_code not in (600, 603, 604): front.ip_manager.recheck_ip(response.ssl_sock.ip, first_report=False) raise e
def get(): start_time = time.time() content, status, response = front.request("GET", "scan1.xx-net.com", path="/wait?time=5") time_cost = time.time() - start_time xlog.info("GET cost:%f", time_cost) xlog.info("status:%d content:%s", status, content)
def main(): content, status, response = front.request("GET", "http://github.com") print(response) while connect_control.keep_running: time.sleep(1) xlog.info("Exiting heroku_front module...")
def main(): content, status, response = front.request("GET", "center6.xx-net.net", "/") print(response) while connect_control.keep_running: time.sleep(1) xlog.info("Exiting gae_proxy module...") xlog.debug("## GAEProxy set keep_running: %s", connect_control.keep_running)
def get(): start_time = time.time() content, status, response = front.request("GET", "scan1.xx-net.net", "/", timeout=10) #content, status, response = front.request("GET", "dns.xx-net.net", path="/query?domain=www.google.com") if isinstance(content, memoryview): content = content.tobytes() time_cost = time.time() - start_time xlog.info("GET cost:%f", time_cost) xlog.info("status:%d content:%s", status, content) front.stop()