-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutiles.py
More file actions
57 lines (47 loc) · 1.25 KB
/
utiles.py
File metadata and controls
57 lines (47 loc) · 1.25 KB
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
import ipaddress
class Validator:
def __init__(self):
pass
def validate_input(self, args):
name, ip, port, method, interval = args[1:]
if (
not self.validate_ip(ip)
or not self.validate_port(port)
or not self.validate_method(method)
or not self.validate_interval(interval)
):
return False
return True
def validate_ip(self, ip):
try:
if not ipaddress.ip_address(ip).is_private:
return True
return False
except:
return False
def validate_port(self, port):
try:
port = int(port)
if port > 0 and port <= 65535:
return True
return False
except:
return False
def validate_method(self, method):
if method == "ping" or method == "wget":
return True
else:
return False
def validate_interval(self, interval):
try:
interval = int(interval)
if interval >= 60:
return True
return False
except:
return False
class Database:
def __init__(self):
pass
def save(self):
pass