phguo/Auto-nuaa.portal

获取本机 ip 错误导致提示“🚫 Wrong password”

Closed this issue · 1 comments

phguo commented

Bug 只影响 Alfred workflow 和 Hammerspoon 这两个使用 login.pyget_ip 函数的。iOS Shortcuts 获取本机 ip 逻辑不同,不受影响。对 get_ip 函数 做出如下修改。

def get_ip(login_ip='211.65.106.6'):
    # s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    # try:
    #     s.connect(("202.119.64.123", 1))
    #     ip = s.getsockname()[0]
    # except:
    #     ip = "127.0.0.1"
    # finally:
    #     s.close()

    # if ip == "127.0.0.1":
    
    ip_parameters = {
        "callback": "dr1002",
        "v": str(random.randint(1000, 9999))
    }
    ip_url = "http://{}/drcom/chkstatus".format(login_ip)
    ip_request = requests.get(ip_url, params=ip_parameters)
    ip_text_content = ip_request.text.replace('dr1002(', '').replace(')', '')
    ip_json_content = json.loads(ip_text_content)
    ip = ip_json_content["v46ip"]

    return ip
phguo commented

经过一周的测试已可以正常使用。