def main(): port_input = input("Введите номер порта сервера -> ") port_flag = port_validation(port_input) if not port_flag: port_input = DEFAULT_PORT print(f"Выставили порт {port_input} по умолчанию") ip_input = input("Введите ip-адрес сервера -> ") ip_flag = ip_validation(ip_input) if not ip_flag: ip_input = DEFAULT_IP print(f"Выставили ip-адрес {ip_input} по умолчанию") client = Client(ip_input, int(port_input))
def main(): with open("./key.txt", "r") as file: data = file.read() p, g, a = map(int, data.split(" ")) encryption = DiffieHellman(a=a, p=p, g=g) port_input = input("Введите номер порта сервера -> ") port_flag = port_validation(port_input) # Если некорректный ввод if not port_flag: port_input = DEFAULT_PORT print(f"Выставили порт {port_input} по умолчанию") ip_input = input("Введите ip-адрес сервера -> ") ip_flag = ip_validation(ip_input) # Если некорректный ввод if not ip_flag: ip_input = DEFAULT_IP print(f"Выставили ip-адрес {ip_input} по умолчанию") client = Client(ip_input, int(port_input), encryption)
def main(): port_input = input("Введите номер порта для сервера -> ") port_flag = port_validation(port_input, check_open=True) if not port_flag: if not check_port_open(DEFAULT_PORT): print( f"Порт по умолчанию {DEFAULT_PORT} уже занят! Подбираем рандомный порт.." ) stop_flag = False while not stop_flag: current_port = random.randint(49152, 65535) print(f"Сгенерировали рандомный порт {current_port}") stop_flag = check_port_open(current_port) port_input = current_port else: port_input = DEFAULT_PORT print(f"Выставили порт {port_input} по умолчанию") server = Server(int(port_input))