-
Notifications
You must be signed in to change notification settings - Fork 4
/
update-no-ip
executable file
·94 lines (75 loc) · 2.13 KB
/
update-no-ip
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env python
# coding: UTF-8
import sys
import no_ip_updater as noip
# Default user, password and hosts,
# if not defined, they will be prompted
username = None # "username"
password = None # "password"
hosts = None # ["hostname.no-ip.org", "otherhost.servegame.com"]
def run():
import argparse
import getpass
parser = argparse.ArgumentParser(description="Update No-IP hosts")
add_arg = parser.add_argument
add_arg("-u", "--username", action="store", dest="user", type=str, help="No-IP account username" )
add_arg("-p", "--password", action="store", dest="password", type=str, help="account password (NOT RECOMMENDED)" )
add_arg("-i", "--ip", action="store", dest="ip", type=str, help="new host IP" )
add_arg("-f", "--file", action="store", dest="file", nargs="+", help="NOT IMPLEMENTED" )
add_arg("-host", action="store", dest="host", nargs="+", help="host(s) to update" )
args = parser.parse_args()
global username
global password
global hosts
# User and password parameters
if args.user:
if args.password:
username = args.user
password = args.password
else:
password = ""
while not password:
password = getpass.getpass()
username = args.user
# If not passed, prompt
elif not username:
username = ""
while not username:
username = input("Username: ")
password = ""
while not password:
password = getpass.getpass()
if not password:
password = ""
while not password:
password = getpass.getpass("Password: ".format(username))
# Same for hosts
if args.host:
hosts = args.host
elif not hosts:
hosts = ""
while not hosts:
hosts = input("hosts: ").split()
# And for IP
if args.ip:
ip = args.ip
else:
# Detects the current IP
try:
print("Detecting current IP...")
import no_ip_updater.getip as getip
ip = getip.get_ip()
except Exception as err:
print("Can't detect current IP.")
print(err)
raise err
ip = ""
while not ip:
ip = input("ip: ")
print()
print("=== No-IP Updater ===")
noip.updateHosts(username, password, ip, hosts)
print("=====================")
print()
if __name__ == "__main__":
run()