forked from 3kh0/echodown
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser_input.py
41 lines (33 loc) · 2.18 KB
/
user_input.py
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
#
# ███████╗░█████╗░██╗░░██╗░█████╗░ ██████╗░░█████╗░░██╗░░░░░░░██╗███╗░░██╗
# ██╔════╝██╔══██╗██║░░██║██╔══██╗ ██╔══██╗██╔══██╗░██║░░██╗░░██║████╗░██║
# █████╗░░██║░░╚═╝███████║██║░░██║ ██║░░██║██║░░██║░╚██╗████╗██╔╝██╔██╗██║
# ██╔══╝░░██║░░██╗██╔══██║██║░░██║ ██║░░██║██║░░██║░░████╔═████║░██║╚████║
# ███████╗╚█████╔╝██║░░██║╚█████╔╝ ██████╔╝╚█████╔╝░░╚██╔╝░╚██╔╝░██║░╚███║
# ╚══════╝░╚════╝░╚═╝░░╚═╝░╚════╝░ ╚═════╝░░╚════╝░░░░╚═╝░░░╚═╝░░╚═╝░░╚══╝
#
# https://github.com/3kh0/echodown
#
import re
from termcolor import colored
def get_ip_address():
print("Enter IP address:")
ip = input(colored("> ", "yellow"))
if not re.match(r"^(\d{1,3}\.){3}\d{1,3}$", ip):
print(colored("Error: Invalid IP address format at python userInput, promise rejected.", "red"))
print(colored("Exiting due to error, it was your fault :(", "red"))
exit("invalid input")
return ip
def get_protocol():
protocols = {
1: "TCP",
2: "UDP",
3: "HTTP"
}
print("Select a protocol (TCP, UDP, or HTTP):")
protocol = input(colored("> ", "yellow"))
if protocol not in ['TCP', 'UDP','HTTP']:
print(colored("Error: Invalid protocol at python userInput, promise rejected.", "red"))
print(colored("Exiting due to error, it was your fault :(", "red"))
exit("invalid input")
return protocol