예제 #1
0
파일: test.py 프로젝트: Suwmlee/XX-Net
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()
예제 #2
0
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()
예제 #3
0
파일: test.py 프로젝트: chenqiuyan/XX-Net
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()
예제 #4
0
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)
예제 #5
0
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()
예제 #6
0
파일: test.py 프로젝트: chenqiuyan/XX-Net
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()
예제 #7
0
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)
예제 #8
0
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
예제 #9
0
파일: test.py 프로젝트: zz111222333/XX-Net
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)
예제 #10
0
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...")
예제 #11
0
파일: test.py 프로젝트: irwinlove/XX-Net
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)
예제 #12
0
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()
예제 #13
0
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)
예제 #14
0
파일: test.py 프로젝트: Suwmlee/XX-Net
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()
예제 #15
0
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()
예제 #16
0
파일: test.py 프로젝트: LawyerWebber/XX-Net
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)