check_ip.py 文件源码

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

项目:MKFQ 作者: maojingios 项目源码 文件源码
def check_goagent(ssl_sock, appid):
    request_data = 'GET /_gh/ HTTP/1.1\r\nHost: %s.appspot.com\r\n\r\n' % appid
    ssl_sock.send(request_data.encode())
    response = httplib.HTTPResponse(ssl_sock, buffering=True)

    response.begin()

    server_type = response.getheader('Server', "")
    xlog.debug("status:%d", response.status)
    xlog.debug("Server type:%s", server_type)
    if response.status == 404:
        xlog.warn("app check %s status:%d", appid, response.status)
        return False

    if response.status == 503:
        # out of quota
        if "gws" not in server_type and "Google Frontend" not in server_type and "GFE" not in server_type:
            xlog.warn("503 but server type:%s", server_type)
            return False
        else:
            xlog.info("503 server type:%s", server_type)
            return True

    if response.status != 200:
        xlog.warn("app check %s ip:%s status:%d", appid, ip, response.status)
        return False

    content = response.read()
    if "GoAgent" not in content:
        xlog.warn("app check %s content:%s", appid, content)
        return False

    xlog.info("check_goagent ok")
    return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号