network_config_helper.py 文件源码

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

项目:flux_line_bot 作者: blesscat 项目源码 文件源码
def run():
    from fluxclient.upnp.misc import parse_network_config

    kw = {}
    ret = input("Wifi Mode (0=host,1=client)[1]: ").strip("\n")
    if ret == "0":
        kw["wifi_mode"] = "host"
    else:
        kw["wifi_mode"] = "client"

    kw["ssid"] = input("SSID: ").strip("\n")

    ret = input("Is SSID hidden? (y/n)[n]: ").strip("\n")
    if ret.upper() == "Y":
        kw["scan_ssid"] = "1"

    ret = input("Wifi-Protection (0=None,1=WEP,2=WPA2-PSK)[2]: ").strip("\n")
    if ret == "0":
        kw["security"] = "None"
    elif ret == "1":
        kw["security"] = "WEP"
        kw["wepkey"] = input("Wifi password: ").strip("\n")
    else:
        kw["security"] = "WPA2-PSK"
        kw["psk"] = input("Wifi password: ").strip("\n")

    ret = input("Use DHCP? (0=YES,1=NO)[0]: ").strip("\n")
    if ret == "1":
        kw["method"] = "static"
        ipaddr = IPv4Interface(
            input("IP Address (example: \"192.168.0.1/24\"): ").strip("\n"))
        kw["ipaddr"] = str(ipaddr.ip)
        kw["mask"] = int(ipaddr.with_prefixlen.split("/")[-1])
        gw = IPv4Address(input("Gateway: ").strip("\n"))
        kw["route"] = str(gw)
        kw["ns"] = input("DNS: ").strip("\n")
    else:
        kw["method"] = "dhcp"

    return parse_network_config(**kw)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号